| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
System.Wlog.Exception
Description
This module deals with Exception logging.
- logException :: forall e m. (WithLogger m, Exception e) => e -> m ()
- catchLog :: forall e m. (WithLoggerIO m, MonadCatch m, Exception e) => m () -> m ()
Documentation
logException :: forall e m. (WithLogger m, Exception e) => e -> m () Source #
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)