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

Safe HaskellNone
LanguageHaskell2010

Control.Eff.Log.Channel

Description

Concurrent Logging

Synopsis

Documentation

data LogChannel message Source #

A log channel processes logs from the Logs effect by en-queuing them in a shared queue read from a seperate processes. A channel can contain log message filters.

logToChannel :: forall r message a. SetMember Lift (Lift IO) r => LogChannel message -> Eff (Logs message ': r) a -> Eff r a Source #

Send the log messages to a LogChannel.

noLogger :: LogChannel message Source #

Create a LogChannel that will discard all messages sent via forwardLogstochannel or logChannelPutIO.

forkLogger Source #

Arguments

:: Typeable message 
=> Int

Size of the log message input queue. If the queue is full, message are dropped silently.

-> (message -> IO ())

An IO action to log the messages

-> Maybe message

Optional first message to log

-> IO (LogChannel message) 

Fork a new process, that applies a monadic action to all log messages sent via logToChannel or logChannelPutIO.

filterLogChannel :: (message -> Bool) -> LogChannel message -> LogChannel message Source #

Filter logs sent to a LogChannel using a predicate.

joinLogChannel :: Typeable message => LogChannel message -> IO () Source #

Close a log channel created by e.g. forkLogger. Message already enqueue are handled. Subsequent log message will not be handled anymore. If the log channel must be closed immediately, use killLogChannel instead.

killLogChannel :: Typeable message => LogChannel message -> IO () Source #

Close a log channel quickly, without logging messages already in the queue. Subsequent logging requests will not be handled anymore. If the log channel must be closed without loosing any messages, use joinLogChannel instead.

closeLogChannelAfter :: (Typeable message, IsString message) => Maybe message -> LogChannel message -> IO a -> IO a Source #

Run an action and close a LogChannel created by noLogger, forkLogger or filterLogChannel afterwards using joinLogChannel. If a SomeException was thrown, the log channel is killed with killLogChannel, and the exception is re-thrown.

logChannelBracket Source #

Arguments

:: Typeable message 
=> Int

Size of the log message input queue. If the queue is full, message are dropped silently.

-> Maybe message

Optional first message to log

-> (LogChannel message -> IO a)

An IO action that will use the LogChannel, after the action returns (even because of an exception) the log channel is destroyed.

-> LoggingT message IO a 

Wrap LogChannel creation and destruction around a monad action in brackety manner. This function uses joinLogChannel, so en-queued messages are flushed on exit. The resulting action is a LoggingT action, which is essentially a reader for a log handler function in IO.

logChannelPutIO :: LogChannel message -> message -> IO () Source #

Enqueue a log message into a log channel

data JoinLogChannelException Source #

Internal exception to shutdown a LogChannel process created by forkLogger. This exception is handled such that all message already en-queued are handled and then an optional final message is written.

data KillLogChannelException Source #

Internal exception to **immediately** shutdown a LogChannel process created by forkLogger, other than JoinLogChannelException the message queue will not be flushed, not further messages will be logged, except for the optional final message.