Safe Haskell | None |
---|---|
Language | Haskell2010 |
Concurrent Logging
Synopsis
- data LogChannel message
- logToChannel :: forall r message a. SetMember Lift (Lift IO) r => LogChannel message -> Eff (Logs message ': r) a -> Eff r a
- noLogger :: LogChannel message
- forkLogger :: forall message. Typeable message => Int -> (message -> IO ()) -> Maybe message -> IO (LogChannel message)
- filterLogChannel :: (message -> Bool) -> LogChannel message -> LogChannel message
- joinLogChannel :: Typeable message => LogChannel message -> IO ()
- killLogChannel :: Typeable message => LogChannel message -> IO ()
- closeLogChannelAfter :: (Typeable message, IsString message) => Maybe message -> LogChannel message -> IO a -> IO a
- logChannelBracket :: Typeable message => Int -> Maybe message -> (LogChannel message -> IO a) -> LoggingT message IO a
- logChannelPutIO :: LogChannel message -> message -> IO ()
- data JoinLogChannelException
- data KillLogChannelException
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
.
:: 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.
:: 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
|
-> LoggingT message IO a |
Wrap LogChannel
creation and destruction around a monad action in
bracket
y 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.
Instances
Show JoinLogChannelException Source # | |
Defined in Control.Eff.Log.Channel showsPrec :: Int -> JoinLogChannelException -> ShowS # show :: JoinLogChannelException -> String # showList :: [JoinLogChannelException] -> ShowS # | |
Exception JoinLogChannelException Source # | |
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.
Instances
Show KillLogChannelException Source # | |
Defined in Control.Eff.Log.Channel showsPrec :: Int -> KillLogChannelException -> ShowS # show :: KillLogChannelException -> String # showList :: [KillLogChannelException] -> ShowS # | |
Exception KillLogChannelException Source # | |