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. 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
). To simply discard log message, use NoLoggingT
.
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 -> 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
- withChannelLogger :: (MonadBaseControl IO m, MonadIO m) => Int -> LoggingT m a -> LoggingT m a
- newtype NoLoggingT m a = NoLoggingT {
- runNoLoggingT :: 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
- liftLoc :: Loc -> Q Exp
- logDebugN :: MonadLogger m => Text -> m ()
- logInfoN :: MonadLogger m => Text -> m ()
- logWarnN :: MonadLogger m => Text -> m ()
- logErrorN :: MonadLogger m => Text -> m ()
- logOtherN :: MonadLogger m => LogLevel -> Text -> m ()
- logDebugNS :: MonadLogger m => Text -> Text -> m ()
- logInfoNS :: MonadLogger m => Text -> Text -> m ()
- logWarnNS :: MonadLogger m => Text -> Text -> m ()
- logErrorNS :: MonadLogger m => Text -> Text -> m ()
- logOtherNS :: MonadLogger m => Text -> LogLevel -> Text -> m ()
MonadLogger
class Monad m => MonadLogger m whereSource
MonadLogger m => MonadLogger (ResourceT m) | |
MonadLogger m => MonadLogger (ListT m) | |
MonadLogger m => MonadLogger (MaybeT m) | |
MonadLogger m => MonadLogger (IdentityT m) | |
MonadIO m => MonadLogger (LoggingT m) | |
MonadIO m => MonadLogger (NoLoggingT m) | |
MonadLogger m => MonadLogger (ContT r m) | |
(MonadLogger m, Error e) => MonadLogger (ErrorT e m) | |
MonadLogger m => MonadLogger (ReaderT r m) | |
MonadLogger m => MonadLogger (StateT s m) | |
MonadLogger m => MonadLogger (StateT s m) | |
(MonadLogger m, Monoid w) => MonadLogger (WriterT w m) | |
(MonadLogger m, Monoid w) => MonadLogger (WriterT w m) | |
MonadLogger m => MonadLogger (ConduitM i o m) | |
(MonadLogger m, Monoid w) => MonadLogger (RWST r w s m) | |
(MonadLogger m, Monoid w) => MonadLogger (RWST r w s m) | |
MonadLogger m => MonadLogger (Pipe l i o u m) |
Helper transformer
Monad transformer that adds a new logging function.
Since 0.2.2
MonadTrans LoggingT | |
MonadTransControl LoggingT | |
MonadRWS r w s m => MonadRWS r w s (LoggingT m) | |
MonadBaseControl b m => MonadBaseControl b (LoggingT m) | |
MonadBase b m => MonadBase b (LoggingT m) | |
MonadError e m => MonadError e (LoggingT m) | |
MonadReader r m => MonadReader r (LoggingT m) | |
MonadState s m => MonadState s (LoggingT m) | |
MonadWriter w m => MonadWriter w (LoggingT m) | |
Monad m => Monad (LoggingT m) | |
Monad m => Functor (LoggingT m) | |
Monad m => Applicative (LoggingT m) | |
MonadThrow m => MonadThrow (LoggingT m) | |
MonadResource m => MonadResource (LoggingT m) | |
MonadIO m => MonadIO (LoggingT m) | |
MonadCont m => MonadCont (LoggingT m) | |
MonadIO m => MonadLogger (LoggingT m) |
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
:: (MonadBaseControl IO m, MonadIO m) | |
=> Int | Number of mesasges to keep |
-> LoggingT m a | |
-> LoggingT m a |
Within the LoggingT
monad, capture all log messages to a bounded
channel of the indicated size, and only actually log them if there is an
exception.
Since 0.3.2
newtype NoLoggingT m a Source
Monad transformer that disables logging.
Since 0.2.4
NoLoggingT | |
|
MonadTrans NoLoggingT | |
MonadTransControl NoLoggingT | |
MonadBaseControl b m => MonadBaseControl b (NoLoggingT m) | |
MonadBase b m => MonadBase b (NoLoggingT m) | |
Monad m => Monad (NoLoggingT m) | |
Monad m => Functor (NoLoggingT m) | |
Monad m => Applicative (NoLoggingT m) | |
MonadThrow m => MonadThrow (NoLoggingT m) | |
MonadResource m => MonadResource (NoLoggingT m) | |
MonadIO m => MonadIO (NoLoggingT m) | |
MonadIO m => MonadLogger (NoLoggingT m) |
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:
$logDebugS "SomeSource" "This is a debug log message"
Generates a function that takes a LogSource
, a level name and a Text
and logs a LevelOther
message. Usage:
$logOtherS "SomeSource" "My new level" "This is a log message"
TH util
Non-TH logging
logDebugN :: MonadLogger m => Text -> m ()Source
logInfoN :: MonadLogger m => Text -> m ()Source
logWarnN :: MonadLogger m => Text -> m ()Source
logErrorN :: MonadLogger m => Text -> m ()Source
logOtherN :: MonadLogger m => LogLevel -> Text -> m ()Source
Non-TH logging with source
logDebugNS :: MonadLogger m => Text -> Text -> m ()Source
logInfoNS :: MonadLogger m => Text -> Text -> m ()Source
logWarnNS :: MonadLogger m => Text -> Text -> m ()Source
logErrorNS :: MonadLogger m => Text -> Text -> m ()Source
logOtherNS :: MonadLogger m => Text -> LogLevel -> Text -> m ()Source