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

Safe HaskellNone
LanguageHaskell2010

Control.Eff.LogWriter.Async

Description

This module only exposes a LogWriter for asynchronous logging;

Synopsis

Documentation

withAsyncLogWriter 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.

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

withAsyncLogging Source #

Arguments

:: (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 lmAppName field.

-> Facility

The default RFC-5424 facility to put into the lmFacility field.

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