@hackage / monad-logger-extras

Utilities for composing loggers, coloring output, plus a few orphan instances.

Latest0.1.1.2

About

Metadata

  • Last updated , by alexfmpe
  • License BSD-3-Clause
  • Categories Systems Programming
  • Maintained by: maintainer@obsidian.systems

  • Lottery factor: 4

Links

Installation

Tested Compilers

  1. 9.12.1
  2. 9.10.1
  3. 9.8.2
  4. 9.6.1
  5. 9.4.5
  6. 9.2.5
  7. 9.0.1
  8. 8.10.7
  9. 8.8.1
  10. 8.6.5

Readme

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