log-warper: Flexible, configurable, monadic and pretty logging

[ library, logging, mit, program ] [ Propose Tags ] [ Report a vulnerability ]
Versions [RSS] 0.2.1, 0.2.2, 0.2.3, 0.2.5, 0.3, 0.3.1, 0.4, 0.4.1, 0.4.2, 0.4.3, 0.4.4, 0.4.5, 0.5.0, 0.5.1, 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.2.3.1, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.5.3, 1.6.0, 1.7.0, 1.7.1, 1.7.2, 1.7.3, 1.7.4, 1.7.5, 1.7.6, 1.8.0, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.8.5, 1.8.6, 1.8.7, 1.8.8, 1.8.9, 1.8.10, 1.8.10.1, 1.8.11, 1.9.0 (info)
Change log CHANGES.md
Dependencies aeson (>=1.4 && <1.5), ansi-terminal (>=0.7 && <1.0), base (>=4.9 && <5), containers (>=0.6 && <0.7), deepseq (>=1.4 && <1.5), directory (>=1.3 && <1.4), filepath (>=1.4.1 && <1.5), fmt (>=0.6 && <0.7), lifted-async (>=0.9 && <0.11), log-warper, markdown-unlit (>=0.4), microlens (>=0.4), microlens-platform (>=0.3.9 && <0.5), mmorph (>=1.1 && <1.2), monad-control (>=1.0.1.0 && <1.1), monad-loops (>=0.4.3 && <0.5), mtl (>=2.2.1 && <2.3), o-clock (>=1.1 && <1.2), text (>=1.2.2.1 && <1.3), time (>=1.8 && <2.0), transformers (>=0.5.2 && <0.6), transformers-base (>=0.4.4 && <0.5), universum (>=1.6.0 && <1.7), unix, unordered-containers (>=0.2.7.1), vector (>=0.12 && <0.13), yaml (>=0.11 && <0.12) [details]
Tested with ghc ==8.0.2, ghc ==8.2.2
License MIT
Copyright 2016-2018 Serokell
Author @serokell
Maintainer Serokell <hi@serokell.io>
Category Logging
Home page https://github.com/serokell/log-warper
Uploaded by gromak at 2020-03-04T18:50:32Z
Distributions
Reverse Dependencies 4 direct, 1 indirect [details]
Executables pure-how-to, how-to, play-log
Downloads 29732 total (76 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2020-03-04 [all 2 reports]

Readme for log-warper-1.9.0

[back to package description]

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

    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