MyNixOS website logo
Description

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

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.

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

Metadata

Version

0.1.1.1

Executables (1)

  • bin/readme

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows