monad-logger-extras: Utilities for composing loggers, coloring output, plus a few orphan instances.

[ bsd3, library, program, system ] [ Propose Tags ] [ Report a vulnerability ]

Build composable logging backends for monad-logger. This package includes a few composable backends (including a posix syslog backend) and some extras like log output coloring utilities.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.1.0, 0.1.1.1 (info)
Change log CHANGELOG.md
Dependencies ansi-terminal (>=0.9 && <0.12), base (>=4.12 && <5), bytestring (>=0.10 && <0.12), hsyslog (>=5 && <5.1), monad-logger (>=0.3.36 && <0.4), monad-logger-extras, mtl (>=2.2 && <2.3) [details]
Tested with ghc ==8.6.5 || ==8.8.4 || ==8.10.2
License BSD-3-Clause
Copyright 2020 Obsidian Systems LLC
Author Obsidian Systems LLC
Maintainer maintainer@obsidian.systems
Category System
Home page https://github.com/obsidiansystems/monad-logger-extras
Bug tracker https://github.com/obsidiansystems/monad-logger-extras/issues
Source repo head: git clone git://github.com/obsidiansystems/monad-logger-extras
Uploaded by abrar at 2020-12-01T15:09:08Z
Distributions NixOS:0.1.1.1
Reverse Dependencies 2 direct, 2 indirect [details]
Executables readme
Downloads 677 total (8 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for monad-logger-extras-0.1.1.1

[back to package description]

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