Copyright | (c) Serokell 2016 |
---|---|
License | GPL-3 (see the file LICENSE) |
Maintainer | Serokell <hi@serokell.io> |
Stability | experimental |
Portability | POSIX, GHC |
Safe Haskell | None |
Language | Haskell2010 |
Pretty looking formatters for logger.
Please see System.WLog.Logger for extensive documentation on the logging system.
- stdoutFormatter :: (UTCTime -> Text) -> Bool -> Bool -> LogFormatter a
- stderrFormatter :: (UTCTime -> Text) -> Bool -> LogFormatter a
- stdoutFormatterTimeRounded :: (UTCTime -> Text) -> Int -> LogFormatter a
- centiUtcTimeF :: UTCTime -> Text
- getRoundedTime :: Int -> IO UTCTime
- type LogFormatter a = a -> LogRecord -> Text -> IO Builder
- nullFormatter :: LogFormatter a
- simpleLogFormatter :: Text -> LogFormatter a
- tfLogFormatter :: Text -> Text -> LogFormatter a
- varFormatter :: [(Text, Text)] -> Text -> LogFormatter a
Documentation
stdoutFormatter :: (UTCTime -> Text) -> Bool -> Bool -> LogFormatter a Source #
stderrFormatter :: (UTCTime -> Text) -> Bool -> LogFormatter a Source #
stdoutFormatterTimeRounded :: (UTCTime -> Text) -> Int -> LogFormatter a Source #
centiUtcTimeF :: UTCTime -> Text Source #
Formats UTC time in next format: "%Y-%m-%d %H:%M:%S%Q %Z" but %Q part show only in centiseconds (always 2 digits).
Taken from hslogger
.
type LogFormatter a Source #
= a | The LogHandler that the passed message came from |
-> LogRecord | The log message and priority |
-> Text | The logger name |
-> IO Builder | The formatted log message |
A LogFormatter is used to format log messages. Note that it is
paramterized on the Handler
to allow the formatter to use
information specific to the handler (an example of can be seen in
the formatter used in Syslog
)
nullFormatter :: LogFormatter a Source #
Returns the passed message as is, ie. no formatting is done.
simpleLogFormatter :: Text -> LogFormatter a Source #
Takes a format string, and returns a formatter that may be used to format log messages. The format string may contain variables prefixed with a $-sign which will be replaced at runtime with corresponding values. The currently supported variables are:
$msg
- The actual log message$loggername
- The name of the logger$prio
- The priority level of the message$tid
- The thread ID$pid
- Process ID (Not available on windows)$time
- The current time$utcTime
- The current time in UTC Time
tfLogFormatter :: Text -> Text -> LogFormatter a Source #
Like simpleLogFormatter
but allow the time format to be
specified in the first parameter (this is passed to
formatTime
)
varFormatter :: [(Text, Text)] -> Text -> LogFormatter a Source #
An extensible formatter that allows new substition variables to
be defined. Each variable has an associated IO action that is used
to produce the string to substitute for the variable name. The
predefined variables are the same as for simpleLogFormatter
excluding $time
and $utcTime
.