log-warper-1.8.7: Flexible, configurable, monadic and pretty logging

Safe HaskellNone
LanguageHaskell2010

System.Wlog.Exception

Description

This module deals with Exception logging.

Synopsis

Documentation

logException :: forall e m. (WithLogger m, Exception e) => e -> m () Source #

Logs exception's description with 'Error Severity

catchLog :: forall e m. (WithLoggerIO m, MonadCatch m, Exception e) => m () -> m () Source #

Runs the action, if an exception is raised the logException is executed.

Example

Here is very simple example of usage catchLog on IO functions:

main :: IO ()
main = do
    buildAndSetupYamlLogging productionB "log-config.yaml"
    usingLoggerName "new-logger" runWithExceptionLog

runWithExceptionLog :: (WithLoggerIO m, MonadCatch m) => m ()
runWithExceptionLog = catchLog @IOException (liftIO simpleIOfun)

simpleIOfun :: IO ()
simpleIOfun = getLine >>= readFile >>= putStrLn

and when run you will get:

>>> run-main-from-this-example
> not-existing-filename.txt
[new-logger:ERROR] [2017-12-01 13:07:33.21 UTC] asd: openFile: does not exist (No such file or directory)