MyNixOS website logo
Description

Flexible, configurable, monadic and pretty logging.

This package implements nice and featureful wrapper around hslogger library.

log-warper

Build Status Hackage Stackage LTS Stackage Nightly License: MIT

log-warper is a high level and featureful logging library with monadic interface.

You can jump right into introduction tutorial to see how to write logging with log-warper.

Features

Here is the list of features log-warper provides.

  1. Hierarchical logger names.

    Logger names (tags for loggers) form hierarchy. It means, that "" (also known as mempty or rootLoggerName) is a parent of logger with name "node" which is a parent of logger with name "node.communication". So, logger name comprises dot-separated components. This means that if some logger name doesn't have some settings (like severity or output file) it takes its settings from the closest parent, containing this settings.

  2. Logging initialization from .yaml configuration file.

    Whole logging configuration can be specifed in a single .yaml file. See example here.

  3. Monadic logging interface.

    log-warper uses mtl-style type classes to provide monadic interfaces for logging.

  4. Strict StateT based pure logging.

    See this tutorial on pure logging with log-warper.

  5. Different severity levels of messages with the ability to configure Set of severities.

  6. Output is colored :star:

    When you log messages, you see time of this logging message, logger name, severity and ThreadId. Message formatting is configurable. Color or logged message tag depends on Severity for this message.

  7. Flexible and easy creation of LoggerConfig using monoidal builders and lenses.

    In case .yaml configuration is not enough for you, you can use lens-based EDSL to create configurations. LoggerConfig also implements instances for Semigroup and Monoid so you can combine your configurations from different sources (CLI and .yaml for example).

  8. Logger rotation.

    log-warper supports logger rotation. Yes, there exist logrotate and similar tools. But it's not easy to configure cross-platform (Windows, Linux, OSX) logging rotation with external tools.

  9. Ability to acquire last N megabytes of logs from in-memory cache.

    In case you want to analyze logging messages you can take them from in-memory cache.

Reference guide (FAQ)

Here you can find hints and tips how to achieve desired behavior with log-warper.

  1. How can I redirect all output to stderr?

    • Write termSeveritiesErr: All on top-level of your .yaml file.
  2. How can I disable only Error messages for my logger?

  3. How can I show ThreadId inside log message?

    • Add showTid: true to your .yaml file.
  4. How to easily disable terminal output?

    • Put these lines into .yaml file:
    termSeveritiesOut : []
    termSeveritiesErr : []
    
  5. How can I enable messages with severity Info and higher?

    • Write severity: Info+ inside tree node of your logger settings.
  6. How can I log inside functions like forkIO?

    • Use liftLogIO function. Its Haddock contains nice usage example.
  7. How can I easily log exceptions without throwing them?

Contributing

This project uses universum as default prelude.

Metadata

Version

1.9.0

License

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