GithubHelp home page GithubHelp logo

obsidiansystems / monad-logger-extras Goto Github PK

View Code? Open in Web Editor NEW
2.0 18.0 0.0 20 KB

Build composable logging backends for monad-logger

License: BSD 3-Clause "New" or "Revised" License

Nix 28.32% Haskell 71.68%

monad-logger-extras's Introduction

monad-logger-extras

Haskell Hackage Hackage CI Github CI BSD3 License

Composable logging, syslog integration, and more with monad-logger.

Description

This package provides a way to compose logging actions so that you can conveniently log to multiple destinations. It also includes implementations of a few common logging actions: logging to stdout, stderr, nowhere (similar to NoLoggingT), and to a posix syslog (using hsyslog).

Logs can be emitted in color by using the colorize or colorizeWith function on your Logger.

This package also contains a couple of orphan instances for LoggingT: MonadPlus and Alternative.

Example usage

Watch for the system log message by running:

journalctl --user -t log-test -f

This example can be built and run using cabal (either cabal repl example or cabal build example).

> {-# LANGUAGE OverloadedStrings #-}
> 
> import Control.Monad.Logger
> import Control.Monad.Logger.Extras
> 
> main :: IO ()
> main = do
>   let logger = colorize logToStdout <> logToStderr <> logToSyslog "log-test"
>   flip runLoggerLoggingT logger $ do
>     logInfoN "This is a test. You should see this on stdout, stderr, and in your system log."
>     logDebugN "This is a debug message."
>     logWarnN "This is a warning."
>     logErrorN "This is an error!"

This should produce output that looks like this (note that the stdout log has been colorized):

Example output

monad-logger-extras's People

Contributors

alexfmpe avatar ali-abrar avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

monad-logger-extras's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.