Safe Haskell | None |
---|
This module provides the facilities needed for a decoupled logging system.
The MonadLogger
class is implemented by monads that give access to a
logging facility. Note that although IO
, Identity
and ST
are
instances of MonadLogger
, they will discard all log messages. If you're
defining a custom monad, then you may define an instance of MonadLogger
that routes the log messages to the appropriate place (e.g., that's what
yesod-core
's GHandler
does). Otherwise, you may use the LoggingT
monad included in this module (see runStderrLoggingT
).
As a user of the logging facility, we provide you some convenient Template
Haskell splices that use the MonadLogger
class. They will record their
source file and position, which is very helpful when debugging. See
logDebug
for more information.
- class Monad m => MonadLogger m where
- monadLoggerLog :: ToLogStr msg => Loc -> LogLevel -> msg -> m ()
- monadLoggerLogSource :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> m ()
- data LogLevel
- = LevelDebug
- | LevelInfo
- | LevelWarn
- | LevelError
- | LevelOther Text
- type LogSource = Text
- newtype LoggingT m a = LoggingT {}
- runStderrLoggingT :: MonadIO m => LoggingT m a -> m a
- runStdoutLoggingT :: MonadIO m => LoggingT m a -> m a
- logDebug :: Q Exp
- logInfo :: Q Exp
- logWarn :: Q Exp
- logError :: Q Exp
- logOther :: Text -> Q Exp
- logDebugS :: Q Exp
- logInfoS :: Q Exp
- logWarnS :: Q Exp
- logErrorS :: Q Exp
- logOtherS :: Q Exp
MonadLogger
class Monad m => MonadLogger m whereSource
monadLoggerLog :: ToLogStr msg => Loc -> LogLevel -> msg -> m ()Source
monadLoggerLogSource :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> m ()Source
Helper transformer
Monad transformer that adds a new logging function.
Since 0.2.2
runStderrLoggingT :: MonadIO m => LoggingT m a -> m aSource
Run a block using a MonadLogger
instance which prints to stderr.
Since 0.2.2
runStdoutLoggingT :: MonadIO m => LoggingT m a -> m aSource
Run a block using a MonadLogger
instance which prints to stdout.
Since 0.2.2
TH logging
Generates a function that takes a Text
and logs a LevelDebug
message. Usage:
$(logDebug) "This is a debug log message"
logOther :: Text -> Q ExpSource
Generates a function that takes a Text
and logs a LevelOther
message. Usage:
$(logOther "My new level") "This is a log message"
TH logging with source
Generates a function that takes a LogSource
and Text
and logs a LevelDebug
message. Usage:
$logDebug "SomeSource" "This is a debug log message"