Safe Haskell | None |
---|---|
Language | Haskell2010 |
Asynchronous Logging
Documentation
:: (LogsTo IO e, Lifted IO e, MonadBaseControl IO (Eff e), Integral len) | |
=> len | Size of the log message input queue. If the queue is full, message are dropped silently. |
-> LogWriter IO | |
-> Eff e a | |
-> Eff e a |
Fork a new process in which the given log message writer, will listen on a message queue, to which all log message will be relayed.
If an exception is received, the logging process will be killed.
Log messages are deeply evaluated before being sent to the logger process, to prevent that lazy evaluation leads to heavy work being done in the logger process instead of the caller process.
Example:
exampleAsyncLogging :: IO () exampleAsyncLogging = runLift $ withSomeLogging @IO $ withAsyncLogging (1000::Int) consoleLogWriter $ do logMsg "test 1" logMsg "test 2" logMsg "test 3"