extensible-effects-concurrent-0.20.0: Message passing concurrency as extensible-effect

Safe HaskellNone
LanguageHaskell2010

Control.Eff.Log.Channel

Description

Asynchronous Logging

Synopsis

Documentation

withAsyncLogging Source #

Arguments

:: (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"