tinylog-0.12.1: Simplistic logging using fast-logger.

Safe HaskellNone
LanguageHaskell2010

System.Logger.Class

Description

The MonadLogger type-class and associated functions.

Synopsis

Documentation

format :: Settings -> DateFormat Source

The time and date format used for the timestamp part of a log line.

delimiter :: Settings -> ByteString Source

Delimiter string which separates log line parts.

netstrings :: Settings -> Bool Source

Whether to use netstring encoding for log lines.

data Level Source

Constructors

Trace 
Debug 
Info 
Warn 
Error 
Fatal 

data Output Source

Constructors

StdOut 
StdErr 
Path FilePath 

Instances

iso8601UTC :: DateFormat Source

ISO 8601 date-time format.

new :: MonadIO m => Settings -> m Logger Source

Create a new Logger with the given Settings. Please note that the logLevel can be dynamically adjusted by setting the environment variable LOG_LEVEL accordingly. Likewise the buffer size can be dynamically set via LOG_BUFFER and netstrings encoding can be enabled with LOG_NETSTR=True

Since version 0.11 one can also use LOG_LEVEL_MAP to specify log levels per (named) logger. The syntax uses standard haskell syntax for association lists of type [(Text, Level)]. For example:

$ LOG_LEVEL=Info LOG_LEVEL_MAP='[("foo", Warn), ("bar", Trace)]' cabal repl
> g1 <- new defSettings
> let g2 = clone (Just "foo") g
> let g3 = clone (Just "bar") g
> let g4 = clone (Just "xxx") g
> logLevel (settings g1)
Info
> logLevel (settings g2)
Warn
> logLevel (settings g3)
Trace
> logLevel (settings g4)
Info

create :: MonadIO m => Output -> m Logger Source

Invokes new with default settings and the given output as log sink.

level :: Logger -> Level Source

Inspect this logger's threshold.

flush :: MonadIO m => Logger -> m () Source

Force buffered bytes to output sink.

close :: MonadIO m => Logger -> m () Source

Closes the logger.

clone :: Maybe Text -> Logger -> Logger Source

Clone the given logger and optionally give it a name (use Nothing to clear).

If logLevelOf returns a custom Level for this name then the cloned logger will use it for its log messages.

class Monad m => MonadLogger m where Source

Methods

log :: Level -> (Msg -> Msg) -> m () Source

trace :: MonadLogger m => (Msg -> Msg) -> m () Source

Abbreviation for log using the corresponding log level.

debug :: MonadLogger m => (Msg -> Msg) -> m () Source

Abbreviation for log using the corresponding log level.

info :: MonadLogger m => (Msg -> Msg) -> m () Source

Abbreviation for log using the corresponding log level.

warn :: MonadLogger m => (Msg -> Msg) -> m () Source

Abbreviation for log using the corresponding log level.

err :: MonadLogger m => (Msg -> Msg) -> m () Source

Abbreviation for log using the corresponding log level.

fatal :: MonadLogger m => (Msg -> Msg) -> m () Source

Abbreviation for log using the corresponding log level.