Flexible, configurable, monadic and pretty logging.
This package implements nice and featureful wrapper around hslogger library.
log-warper
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.
Hierarchical logger names.
Logger names (tags for loggers) form hierarchy. It means, that
""(also known asmemptyorrootLoggerName) 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.Logging initialization from
.yamlconfiguration file.Whole logging configuration can be specifed in a single
.yamlfile. See example here.Monadic logging interface.
log-warperusesmtl-style type classes to provide monadic interfaces for logging.Strict
StateTbased pure logging.See this tutorial on pure logging with
log-warper.Different severity levels of messages with the ability to configure
Setof severities.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 onSeverityfor this message.Flexible and easy creation of
LoggerConfigusing monoidal builders and lenses.In case
.yamlconfiguration is not enough for you, you can uselens-based EDSL to create configurations.LoggerConfigalso implements instances forSemigroupandMonoidso you can combine your configurations from different sources (CLI and.yamlfor example).Logger rotation.
log-warpersupports logger rotation. Yes, there existlogrotateand similar tools. But it's not easy to configure cross-platform (Windows, Linux, OSX) logging rotation with external tools.Ability to acquire last
Nmegabytes 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.
How can I redirect all output to stderr?
- Write
termSeveritiesErr: Allon top-level of your.yamlfile.
- Write
How can I disable only Error messages for my logger?
- Use
excludeErrorfunction.
- Use
How can I show
ThreadIdinside log message?- Add
showTid: trueto your.yamlfile.
- Add
How to easily disable terminal output?
- Put these lines into
.yamlfile:
termSeveritiesOut : [] termSeveritiesErr : []- Put these lines into
How can I enable messages with severity
Infoand higher?- Write
severity: Info+inside tree node of your logger settings.
- Write
How can I log inside functions like
forkIO?- Use
liftLogIOfunction. Its Haddock contains nice usage example.
- Use
How can I easily log exceptions without throwing them?
- Use functions from
System.Wlog.Exceptionsmodule.
- Use functions from
Contributing
This project uses
universumas default prelude.