log-warper
Flexible, configurable, monadic and pretty logging
https://github.com/serokell/log-warper
Version on this page: | 1.8.11 |
LTS Haskell 11.22: | 1.8.11 |
Stackage Nightly 2018-03-12: | 1.8.10.1 |
Latest on Hackage: | 1.9.0 |
log-warper-1.8.11@sha256:563b26e8e7700eea5c181d8c52bf88adf1aeb15f8100974aa8090abb900d30fe,6898
Module documentation for 1.8.11
- System
- System.Wlog
- System.Wlog.CanLog
- System.Wlog.Exception
- System.Wlog.FileUtils
- System.Wlog.Formatter
- System.Wlog.HasLoggerName
- System.Wlog.IOLogger
- System.Wlog.Launcher
- System.Wlog.LogHandler
- System.Wlog.LoggerConfig
- System.Wlog.LoggerName
- System.Wlog.LoggerNameBox
- System.Wlog.PureLogging
- System.Wlog.Severity
- System.Wlog.Terminal
- System.Wlog
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 asmempty
orrootLoggerName
) 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
.yaml
configuration file.Whole logging configuration can be specifed in a single
.yaml
file. See example here. -
Monadic logging interface.
log-warper
usesmtl
-style type classes to provide monadic interfaces for logging. -
Strict
StateT
based pure logging.See this tutorial on pure logging with
log-warper
. -
Different severity levels of messages with the ability to configure
Set
of 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 onSeverity
for this message. -
Flexible and easy creation of
LoggerConfig
using monoidal builders and lenses.In case
.yaml
configuration is not enough for you, you can uselens
-based EDSL to create configurations.LoggerConfig
also implements instances forSemigroup
andMonoid
so you can combine your configurations from different sources (CLI and.yaml
for example). -
Logger rotation.
log-warper
supports logger rotation. Yes, there existlogrotate
and similar tools. But it’s not easy to configure cross-platform (Windows, Linux, OSX) logging rotation with external tools. -
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
.
-
How can I redirect all output to stderr?
- Write
termSeveritiesErr: All
on top-level of your.yaml
file.
- Write
-
How can I disable only Error messages for my logger?
- Use
excludeError
function.
- Use
-
How can I show
ThreadId
inside log message?- Add
showTid: true
to your.yaml
file.
- Add
-
How to easily disable terminal output?
- Put these lines into
.yaml
file:
termSeveritiesOut : [] termSeveritiesErr : []
- Put these lines into
-
How can I enable messages with severity
Info
and higher?- Write
severity: Info+
inside tree node of your logger settings.
- Write
-
How can I log inside functions like
forkIO
?- Use
liftLogIO
function. Its Haddock contains nice usage example.
- Use
-
How can I easily log exceptions without throwing them?
- Use functions from
System.Wlog.Exceptions
module.
- Use functions from
Contributing
This project uses
universum
as default prelude
Changes
1.8.11
- Resolve LW-34 bug, which was causing improper message handling in nonexisting loggers
1.8.10.1
- Make
o-clock
non-optional dependency.
1.8.10
- Remove exception handler from simple logger, which would catch all exceptions, even asynchronous ones.
1.8.9
- Bump up lower bounds for
universum
ando-clock
packages.
1.8.8
- Increase upper bound for
ansi-terminal
to< 0.9
.
1.8.7
- #52:
Add
System.Wlog.Concurrent
module forghc-8.2.2
which allows to run action in parallel with logging.
1.8.6
- Bump up
universum
tov1.0.4
.
1.8.5
- #89:
Add upper-bounds for dependencies. Also use
build-tool-depends
field formarkdown-unlit
.
1.8.4
- #86: Add lens for changing properties of the particular logger.
- Ungrade
universum
to the1.0.2
.
1.8.3
- #79:
Add
launchWithConfig
toLauncher
module.
1.8.2
- Migrate to
universum-1.0.0
. - #71:
Use
microlens-platform
instead oflens
.LoggerMap
is now has fieldLoggerName
instead ofText
.zoomLogger
is now work withLoggerName
instead ofText
. RemoveLogHandler.Syslog
module andnetwork
library. Removeextra
,errors
,exceptions
,hashable
,text-format
,formatting
dependencies. RemoveloggerNameF
function. Changelens
tomicrolens-mtl
in tests.
1.8.1
- #75:
Bump up
universum
lower bound.
1.8.0
- #55:
Return back
lcFilePrefix
field inLoggerConfig
, rename tolcLogsDirectory
.
1.7.6
- Upgrade
universum
to version0.9.1
. AddSemigroup
instances.
1.7.5
- Relax
containers
package dependency from>= 0.5.10.2
to>= 0.5.7.1
. Also use stable LTS for building package.
1.7.4
- #55:
Remove
lcFilePrefix
field fromLoggerConfig
.
1.7.3
- #61:
Add
launchFromFile
,defaultConfig
andlaunchSimpleLogging
functions.
1.7.2
- #57:
Add
Exception
module withlogException
andcatchLog
functions. - #60:
Fix documentation for
termSeveritiesOut
andtermSeveritiesErr
. - #63: Timestamp rounding by powers of 10.
1.7.1
- Bump
containers
to version0.5.10
.
1.7.0
- #48:
Output for severities is now configured in config file with
termSeveritiesOut
andtermSeveritiesErr
for writing intostdout
andstderr
accordingly. Default behavior:Errors
intostderr
, all other intostdout
. - In yaml config file added new keywords for dealing with
Severities
: ‘All’ – all severities, ‘X+’ – severities greater or equal to X. - Changed .yaml format: logger severity receives set of severities (
Severities
). - #32:
Changed .yaml format:
LoggerTree
should be written under ‘loggerTree:’. - #49:
Add
WithLoggerIO
constraint. - #50:
Add
liftLogIO
function intoCanLog
module.
1.6.0
Error
is now printed only tostderr
, all other messages tostdout
.Logger
severity is nowSet Severity
.- Interface changes: functions which worked with
Severity
now work withSet Severity
. - Remove
releaseAllHandlers
,streamHandlerWithLock
,trapLogging
,debugM
,errorM
,infoM
,noticeM
,warningM
. - Rename
Wrapper
module toTerminal
. - Rename
Handler
module toLogHandler
. - Rename
Logger
module toIOLogger
. - Move
setSeverity
andsetSeverityMaybe
toIOLogger
. - Lift all functions inside
IOLogger
module toMonadIO
. handle
fromLogHandler
module is renamed tologHandlerMessage
and moved out of type classLogHandler
.
1.5.3
- Add
launchNamedPureLogWith
toPureLogging
- Improve documentation for
launchNamedPureLog
1.5.2
- Add
logPureAction
toPureLogging
. - Add
withSublogger
toHasLoggerName
.
1.5.1
- Add
usingNamedPureLogger
toPureLogging
.
1.5.0
- Replace
String
toText
inLoggerName
. - Rename
LoggerName
field name togetLoggerName
. - Rename
getLoggerName
ofHasLoggerName
class toaskLoggerName
. - Use
LoggerName
instead ofText
where possible. - Make separate
HasLoggerName
module. - Make separate
PureLogging
module. - Remove
safecopy
dependency and refactor code.
1.4.1
- Add
logEvents
function to log[LogEvent]
with proper logName.
1.4.0
- Add ability to specify custom logging action.
1.3.4
- Correct logger config parsing
1.3.3
- Fixed a bug related to ugly output to stdout even when it was turned off.
1.3.2
- Minor dependencies update.
1.3.1
- Fix minor bug with stdout severity.
1.3.0
- Allow to use arbitrary text formatter function.
1.2.4
- Add ability to specify time format for logs.
- Some space leaks elimination:
- The
MemoryQueue
has been partially reworked to get rid of the “inline” State manipulation; - Strings have been dropped almost everywhere in favour of
Text
; - A
LogFormatter
has been reworked to yield aIO Builder
; replaceVarM
has been reworked to be pure and to work with builders rather than plain Text/Strings;- The pure logger has been reworked to use strict’s
StateT
instead of WriterT; - The pure logger have been polished to drop instances which required the
UndecidableInstances
pragma; - The
Sized
instance forText
has been reworked and multiplied by a constant factor of 16 (see below).
- The
1.2.3
- Now we create a directory for log files if it’s missing.
1.2.2
- Fixed memory leak (PR #17).
1.2.1
- Supports Unix paths in log configs even on Windows.
1.2.0
- Uses universum-0.6.1.
1.1.4
- Add
CanLog
andHasLoggerName
instances for both strict and lazyState
.
1.1.3
- Add config parameter to print
ThreadId
optionally. - Boolean monoidal builders for
LoggerConfig
now set boolean parameter to default ≠mempty
parameter.