| 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 |
System.Wlog.Launcher
Description
Parser for configuring and initializing logger from YAML file. Logger configuration should look like this:
rotation: # [optional] parameters for logging rotation
logLimit: 1024 # max size of log file in bytes
keepFiles: 3 # number of files with logs to keep including current one
loggerTree:
severity: Warning+ # severities for «root» logger
node: # logger named «node»
severity: Warning+ # severities for logger «node»
comm: # logger named «node.comm»
severity: Info+ # severity for logger «node.comm»
file: patak.jpg # messages will be also printed to patak.jpgAnd this configuration corresponds two loggers with LoggerName's
node and node.comm.
Synopsis
- buildAndSetupYamlLogging :: MonadIO m => LoggerConfig -> FilePath -> m ()
- defaultConfig :: LoggerName -> LoggerConfig
- launchFromFile :: (MonadIO m, MonadMask m) => FilePath -> LoggerName -> LoggerNameBox m a -> m a
- launchSimpleLogging :: (MonadIO m, MonadMask m) => LoggerName -> LoggerNameBox m a -> m a
- launchWithConfig :: (MonadIO m, MonadMask m) => LoggerConfig -> LoggerName -> LoggerNameBox m a -> m a
- parseLoggerConfig :: MonadIO m => FilePath -> m LoggerConfig
- setupLogging :: MonadIO m => Maybe (UTCTime -> Text) -> LoggerConfig -> m ()
Documentation
buildAndSetupYamlLogging :: MonadIO m => LoggerConfig -> FilePath -> m () Source #
Applies given builder to parsed logger config and initializes logging.
defaultConfig :: LoggerName -> LoggerConfig Source #
Default logging configuration with the given LoggerName.
Enabled flags:
ltSeverityof the root logger is set towarningPlus(Warningand upper)ltSeverityfor the given logger is set todebugPlus(Debugand upper)lcShowTimeis set to 'Any True' which means that time is shown in the log messages.lcConsoleActionis set todefaultHandleActionwhich turns the console output on.
Example
defaultConfig "example" will produce such configurations:
rotation: null
showTid: false
showTime: true
printOutput: true
logTree:
_ltSubloggers:
example:
_ltSubloggers: {}
_ltSeverity:
- Debug
- Info
- Notice
- Warning
- Error
_ltFiles: []
_ltSeverity:
- Warning
- Error
_ltFiles: []
termSeveritiesOut: null
filePrefix: null
termSeveritiesErr: null
launchFromFile :: (MonadIO m, MonadMask m) => FilePath -> LoggerName -> LoggerNameBox m a -> m a Source #
Initializes logging using given FilePath to logger configurations,
runs the action with the given LoggerName.
launchSimpleLogging :: (MonadIO m, MonadMask m) => LoggerName -> LoggerNameBox m a -> m a Source #
Set ups the logging with defaultConfig and runs the action with the given LoggerName.
Example
Here we can see very simple working example of logging:
ghci> :{
ghci| launchSimpleLogging "app" $ do
ghci| logDebug "Debug message"
ghci| putStrLn "Usual printing"
ghci| logInfo "Job's done!"
ghci| :}
[app:DEBUG] [2017-12-07 11:25:06.47 UTC] Debug message
Usual printing
[app:INFO] [2017-12-07 11:25:06.47 UTC] Job's done!
launchWithConfig :: (MonadIO m, MonadMask m) => LoggerConfig -> LoggerName -> LoggerNameBox m a -> m a Source #
Sets up given logging configurations,
runs the action with the given LoggerName.
parseLoggerConfig :: MonadIO m => FilePath -> m LoggerConfig Source #
Parses logger config from given file path.
setupLogging :: MonadIO m => Maybe (UTCTime -> Text) -> LoggerConfig -> m () Source #
This function traverses LoggerConfig initializing all subloggers
with Severities and redirecting output in file handlers.
See LoggerConfig for more details.