| Copyright | (c) Seller Labs 2016 |
|---|---|
| License | Apache 2.0 |
| Maintainer | matt@sellerlabs.com |
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | None |
| Language | Haskell2010 |
Control.Monad.Logger.Prefix
Contents
Description
This module exports the LogPrefixT monad transfomer. This transformer adds
a given prefix to a MonadLogger context, allowing you to make your logs a bit
more greppable without including much boilerplate. The prefixes can be nested
easily.
The function prefixLogs is the most convenient way to use the library. All you
have to do is use the function to add the prefix, and it Just Works. Here's an
example:
someLoggingFunction :: MonadLogger m => m ()
someLoggingFunction = do
$(logDebug) "No prefix here"
"foo" `prefixLogs` do
$(logDebug) "There's a [foo] there!
"bar" `prefixLogs` do
$(logDebug) "Now there's a [foo] *and* a [bar]"
Synopsis
- data LogPrefixT m a
- prefixLogs :: Text -> LogPrefixT m a -> m a
- module Control.Monad.Logger
LogPrefixT
data LogPrefixT m a Source #
LogPrefixT is a monad transformer that prepends a bit of text to each
logging action in the current MonadLogger context. The internals are
currently implemented as a wrapper around ReaderT LogStr.
Instances
prefixLogs :: Text -> LogPrefixT m a -> m a infixr 5 Source #
This function runs the underlying MonadLogger instance with a prefix
using the LogPrefixT transformer.
>>>:set -XOverloadedStrings>>>let l = logDebugN "bar">>>runStdoutLoggingT (prefixLogs "foo" (logDebugN "bar\n"))[Debug] [foo] bar ...
module Control.Monad.Logger