Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module only exposes a LogWriter
for asynchronous logging;
Synopsis
- withAsyncLogWriter :: (LogsTo IO e, Lifted IO e, MonadBaseControl IO (Eff e), Integral len) => len -> Eff e a -> Eff e a
- withAsyncLogging :: (Lifted IO e, MonadBaseControl IO (Eff e), Integral len) => LogWriter IO -> len -> Text -> Facility -> LogPredicate -> Eff (Logs ': (LogWriterReader IO ': e)) a -> Eff e a
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. |
-> Eff e a | |
-> Eff e a |
Move the current LogWriter
into its own thread.
A bounded queue is used to forward logs to the process.
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:
exampleAsyncLogWriter :: IO () exampleAsyncLogWriter = runLift $ withLogging consoleLogWriter $ withAsyncLogWriter (1000::Int) $ do logMsg "test 1" logMsg "test 2" logMsg "test 3"
:: (Lifted IO e, MonadBaseControl IO (Eff e), Integral len) | |
=> LogWriter IO | |
-> len | Size of the log message input queue. If the queue is full, message are dropped silently. |
-> Text | The default application name to put into the |
-> Facility | The default RFC-5424 facility to put into the |
-> LogPredicate | The inital predicate for log messages, there are some pre-defined in Control.Eff.Log.Message |
-> Eff (Logs ': (LogWriterReader IO ': e)) a | |
-> Eff e a |
This is a wrapper around withAsyncLogWriter
and withIoLogging
.
Example:
exampleWithAsyncLogging :: IO () exampleWithAsyncLogging = runLift $ withAsyncLogWriter consoleLogWriter (1000::Int) "my-app" local0 allLogMessages $ do logMsg "test 1" logMsg "test 2" logMsg "test 3"