Control.Monad.Logger

monad-logger-0.3.19: A class of monads which can log messages.

Safe Haskell | Trustworthy
Language | Haskell98

Control.Monad.Logger

Contents

- MonadLogger
- Re-export from fast-logger
- Helper transformer
- TH logging
- TH logging of showable values
- TH logging with source
- TH util
- Non-TH logging
- Non-TH logging with source
- Callstack logging
- utilities for defining your own loggers

Description

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.

Synopsis

- class Monad m => MonadLogger m where
- class (MonadLogger m, MonadIO m) => MonadLoggerIO m where
- data LogLevel
  - = LevelDebug
  - | LevelInfo
  - | LevelWarn
  - | LevelError
  - | LevelOther Text
- type LogSource = Text
- data LogStr :: *
- class ToLogStr msg where
  - toLogStr :: msg -> LogStr
- newtype LoggingT m a = LoggingT {
  - runLoggingT :: (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) -> m a
  }
- runStderrLoggingT :: MonadIO m => LoggingT m a -> m a
- runStdoutLoggingT :: MonadIO m => LoggingT m a -> m a
- runChanLoggingT :: MonadIO m => Chan (Loc, LogSource, LogLevel, LogStr) -> LoggingT m a -> m a
- unChanLoggingT :: (MonadLogger m, MonadIO m) => Chan (Loc, LogSource, LogLevel, LogStr) -> m ()
- withChannelLogger :: (MonadBaseControl IO m, MonadIO m) => Int -> LoggingT m a -> LoggingT m a
- filterLogger :: (LogSource -> LogLevel -> Bool) -> 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
- logDebugSH :: Q Exp
- logInfoSH :: Q Exp
- logWarnSH :: Q Exp
- logErrorSH :: Q Exp
- logOtherSH :: 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 ()
- logDebugCS :: MonadLogger m => CallStack -> Text -> m ()
- logInfoCS :: MonadLogger m => CallStack -> Text -> m ()
- logWarnCS :: MonadLogger m => CallStack -> Text -> m ()
- logErrorCS :: MonadLogger m => CallStack -> Text -> m ()
- logOtherCS :: MonadLogger m => CallStack -> LogLevel -> Text -> m ()
- defaultLogStr :: Loc -> LogSource -> LogLevel -> LogStr -> LogStr
- data Loc :: * = Loc {
  - loc_filename :: String
  - loc_package :: String
  - loc_module :: String
  - loc_start :: CharPos
  - loc_end :: CharPos
  }

# MonadLogger

class Monad m => MonadLogger m where #

A `Monad` which has the ability to log messages in some manner.

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> m () #

monadLoggerLog :: (MonadTrans t, MonadLogger (t m), ToLogStr msg) => Loc -> LogSource -> LogLevel -> msg -> t m () #

Instances

MonadLogger m => MonadLogger (MaybeT m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> MaybeT m () #
MonadLogger m => MonadLogger (ListT m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ListT m () #
MonadLogger m => MonadLogger (ResourceT m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ResourceT m () #
MonadIO m => MonadLogger (LoggingT m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> LoggingT m () #
Monad m => MonadLogger (NoLoggingT m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> NoLoggingT m () #
(MonadLogger m, Monoid w) => MonadLogger (WriterT w m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> WriterT w m () #
(MonadLogger m, Monoid w) => MonadLogger (WriterT w m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> WriterT w m () #
MonadLogger m => MonadLogger (StateT s m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> StateT s m () #
MonadLogger m => MonadLogger (StateT s m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> StateT s m () #
(MonadLogger m, Error e) => MonadLogger (ErrorT e m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ErrorT e m () #
MonadLogger m => MonadLogger (ExceptT e m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ExceptT e m () #
MonadLogger m => MonadLogger (IdentityT * m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> IdentityT * m () #
MonadLogger m => MonadLogger (ReaderT * r m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ReaderT * r m () #
MonadLogger m => MonadLogger (ConduitM i o m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ConduitM i o m () #
MonadLogger m => MonadLogger (ContT * r m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ContT * r m () #
(MonadLogger m, Monoid w) => MonadLogger (RWST r w s m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> RWST r w s m () #
(MonadLogger m, Monoid w) => MonadLogger (RWST r w s m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> RWST r w s m () #
MonadLogger m => MonadLogger (Pipe l i o u m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> Pipe l i o u m () #

class (MonadLogger m, MonadIO m) => MonadLoggerIO m where #

An extension of `MonadLogger` for the common case where the logging action is a simple `IO` action. The advantage of using this typeclass is that the logging function itself can be extracted as a first-class value, which can make it easier to manipulate monad transformer stacks, as an example.

Since 0.3.10

Methods

askLoggerIO :: m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

Request the logging function itself.

Since 0.3.10

askLoggerIO :: (MonadTrans t, MonadLogger (t m), MonadIO (t m)) => t m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

Request the logging function itself.

Since 0.3.10

Instances

MonadLoggerIO m => MonadLoggerIO (MaybeT m) # |
Methods askLoggerIO :: MaybeT m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #
MonadLoggerIO m => MonadLoggerIO (ListT m) # |
Methods askLoggerIO :: ListT m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #
MonadLoggerIO m => MonadLoggerIO (ResourceT m) # |
Methods askLoggerIO :: ResourceT m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #
MonadIO m => MonadLoggerIO (LoggingT m) # |
Methods askLoggerIO :: LoggingT m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #
MonadIO m => MonadLoggerIO (NoLoggingT m) # |
Methods askLoggerIO :: NoLoggingT m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #
(MonadLoggerIO m, Monoid w) => MonadLoggerIO (WriterT w m) # |
Methods askLoggerIO :: WriterT w m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #
(MonadLoggerIO m, Monoid w) => MonadLoggerIO (WriterT w m) # |
Methods askLoggerIO :: WriterT w m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #
MonadLoggerIO m => MonadLoggerIO (StateT s m) # |
Methods askLoggerIO :: StateT s m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #
MonadLoggerIO m => MonadLoggerIO (StateT s m) # |
Methods askLoggerIO :: StateT s m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #
(MonadLoggerIO m, Error e) => MonadLoggerIO (ErrorT e m) # |
Methods askLoggerIO :: ErrorT e m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #
MonadLoggerIO m => MonadLoggerIO (ExceptT e m) # |
Methods askLoggerIO :: ExceptT e m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #
MonadLoggerIO m => MonadLoggerIO (IdentityT * m) # |
Methods askLoggerIO :: IdentityT * m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #
MonadLoggerIO m => MonadLoggerIO (ReaderT * r m) # |
Methods askLoggerIO :: ReaderT * r m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #
MonadLoggerIO m => MonadLoggerIO (ConduitM i o m) # |
Methods askLoggerIO :: ConduitM i o m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #
MonadLoggerIO m => MonadLoggerIO (ContT * r m) # |
Methods askLoggerIO :: ContT * r m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #
(MonadLoggerIO m, Monoid w) => MonadLoggerIO (RWST r w s m) # |
Methods askLoggerIO :: RWST r w s m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #
(MonadLoggerIO m, Monoid w) => MonadLoggerIO (RWST r w s m) # |
Methods askLoggerIO :: RWST r w s m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #
MonadLoggerIO m => MonadLoggerIO (Pipe l i o u m) # |
Methods askLoggerIO :: Pipe l i o u m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

data LogLevel #

Constructors

LevelDebug |
LevelInfo |
LevelWarn |
LevelError |
LevelOther Text |

Instances

Eq LogLevel # |
Methods (==) :: LogLevel -> LogLevel -> Bool # (/=) :: LogLevel -> LogLevel -> Bool #
Ord LogLevel # |
Methods compare :: LogLevel -> LogLevel -> Ordering # (<) :: LogLevel -> LogLevel -> Bool # (<=) :: LogLevel -> LogLevel -> Bool # (>) :: LogLevel -> LogLevel -> Bool # (>=) :: LogLevel -> LogLevel -> Bool # max :: LogLevel -> LogLevel -> LogLevel # min :: LogLevel -> LogLevel -> LogLevel #
Read LogLevel # |
Methods readsPrec :: Int -> ReadS LogLevel # readList :: ReadS [LogLevel] # readPrec :: ReadPrec LogLevel # readListPrec :: ReadPrec [LogLevel] #
Show LogLevel # |
Methods showsPrec :: Int -> LogLevel -> ShowS # show :: LogLevel -> String # showList :: [LogLevel] -> ShowS #
Lift LogLevel # |
Methods lift :: LogLevel -> Q Exp #

type LogSource = Text #

# Re-export from fast-logger

data LogStr :: * #

Log message builder. Use (`<>`) to append two LogStr in O(1).

Instances

IsString LogStr |
Methods fromString :: String -> LogStr #
Monoid LogStr |
Methods mempty :: LogStr # mappend :: LogStr -> LogStr -> LogStr # mconcat :: [LogStr] -> LogStr #
ToLogStr LogStr |
Methods toLogStr :: LogStr -> LogStr #

class ToLogStr msg where #

Instances

ToLogStr ByteString |
Methods toLogStr :: ByteString -> LogStr #
ToLogStr ByteString |
Methods toLogStr :: ByteString -> LogStr #
ToLogStr Text |
Methods toLogStr :: Text -> LogStr #
ToLogStr Text |
Methods toLogStr :: Text -> LogStr #
ToLogStr String |
Methods toLogStr :: String -> LogStr #
ToLogStr LogStr |
Methods toLogStr :: LogStr -> LogStr #

# Helper transformer

newtype LoggingT m a #

Monad transformer that adds a new logging function.

Since 0.2.2

Constructors

LoggingT |
Fields runLoggingT :: (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) -> m a

Instances

MonadTrans LoggingT # |
Methods lift :: Monad m => m a -> LoggingT m a #
MonadTransControl LoggingT # |
Associated Types type StT (LoggingT :: (* -> *) -> * -> *) a :: * # Methods liftWith :: Monad m => (Run LoggingT -> m a) -> LoggingT m a # restoreT :: Monad m => m (StT LoggingT a) -> LoggingT m a #
MonadRWS r w s m => MonadRWS r w s (LoggingT m) # |
MonadBaseControl b m => MonadBaseControl b (LoggingT m) # |
Associated Types type StM (LoggingT m :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase (LoggingT m) b -> b a) -> LoggingT m a # restoreM :: StM (LoggingT m) a -> LoggingT m a #
MonadBase b m => MonadBase b (LoggingT m) # |
Methods liftBase :: b α -> LoggingT m α #
MonadError e m => MonadError e (LoggingT m) # |
Methods throwError :: e -> LoggingT m a # catchError :: LoggingT m a -> (e -> LoggingT m a) -> LoggingT m a #
MonadReader r m => MonadReader r (LoggingT m) # |
Methods ask :: LoggingT m r # local :: (r -> r) -> LoggingT m a -> LoggingT m a # reader :: (r -> a) -> LoggingT m a #
MonadState s m => MonadState s (LoggingT m) # |
Methods get :: LoggingT m s # put :: s -> LoggingT m () # state :: (s -> (a, s)) -> LoggingT m a #
MonadWriter w m => MonadWriter w (LoggingT m) # |
Methods writer :: (a, w) -> LoggingT m a # tell :: w -> LoggingT m () # listen :: LoggingT m a -> LoggingT m (a, w) # pass :: LoggingT m (a, w -> w) -> LoggingT m a #
Monad m => Monad (LoggingT m) # |
Methods (>>=) :: LoggingT m a -> (a -> LoggingT m b) -> LoggingT m b # (>>) :: LoggingT m a -> LoggingT m b -> LoggingT m b # return :: a -> LoggingT m a # fail :: String -> LoggingT m a #
Monad m => Functor (LoggingT m) # |
Methods fmap :: (a -> b) -> LoggingT m a -> LoggingT m b # (<$) :: a -> LoggingT m b -> LoggingT m a #
Monad m => Applicative (LoggingT m) # |
Methods pure :: a -> LoggingT m a # (<*>) :: LoggingT m (a -> b) -> LoggingT m a -> LoggingT m b # (*>) :: LoggingT m a -> LoggingT m b -> LoggingT m b # (<*) :: LoggingT m a -> LoggingT m b -> LoggingT m a #
MonadIO m => MonadIO (LoggingT m) # |
Methods liftIO :: IO a -> LoggingT m a #
MonadActive m => MonadActive (LoggingT m) # |
Methods monadActive :: LoggingT m Bool #
MonadThrow m => MonadThrow (LoggingT m) # |
Methods throwM :: Exception e => e -> LoggingT m a #
MonadCatch m => MonadCatch (LoggingT m) # |
Methods catch :: Exception e => LoggingT m a -> (e -> LoggingT m a) -> LoggingT m a #
MonadMask m => MonadMask (LoggingT m) # |
Methods mask :: ((forall a. LoggingT m a -> LoggingT m a) -> LoggingT m b) -> LoggingT m b # uninterruptibleMask :: ((forall a. LoggingT m a -> LoggingT m a) -> LoggingT m b) -> LoggingT m b #
MonadCont m => MonadCont (LoggingT m) # |
Methods callCC :: ((a -> LoggingT m b) -> LoggingT m a) -> LoggingT m a #
MonadResource m => MonadResource (LoggingT m) # |
Methods liftResourceT :: ResourceT IO a -> LoggingT m a #
MonadIO m => MonadLoggerIO (LoggingT m) # |
Methods askLoggerIO :: LoggingT m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #
MonadIO m => MonadLogger (LoggingT m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> LoggingT m () #
type StT LoggingT a # |
type StT LoggingT a = a
type StM (LoggingT m) a # |
type StM (LoggingT m) a = StM m a

runStderrLoggingT :: MonadIO m => LoggingT m a -> m a #

Run a block using a `MonadLogger` instance which prints to stderr.

Since 0.2.2

runStdoutLoggingT :: MonadIO m => LoggingT m a -> m a #

Run a block using a `MonadLogger` instance which prints to stdout.

Since 0.2.2

runChanLoggingT :: MonadIO m => Chan (Loc, LogSource, LogLevel, LogStr) -> LoggingT m a -> m a #

Run a block using a `MonadLogger` instance which writes tuples to an unbounded channel.

The tuples can be extracted (ie. in another thread) with `unChanLoggingT` or a custom extraction funtion, and written to a destination.

Since: 0.3.17

unChanLoggingT :: (MonadLogger m, MonadIO m) => Chan (Loc, LogSource, LogLevel, LogStr) -> m () #

Read logging tuples from an unbounded channel and log them into a `MonadLoggerIO` monad, forever.

For use in a dedicated thread with a channel fed by `runChanLoggingT`.

Since: 0.3.17

withChannelLogger #

Arguments

:: (MonadBaseControl IO m, MonadIO m) |
=> Int | Number of messages 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

filterLogger :: (LogSource -> LogLevel -> Bool) -> LoggingT m a -> LoggingT m a #

Only log messages passing the given predicate function.

This can be a convenient way, for example, to ignore debug level messages.

Since 0.3.13

newtype NoLoggingT m a #

Monad transformer that disables logging.

Since 0.2.4

Constructors

NoLoggingT |
Fields runNoLoggingT :: m a

Instances

MonadTrans NoLoggingT # |
Methods lift :: Monad m => m a -> NoLoggingT m a #
MonadTransControl NoLoggingT # |
Associated Types type StT (NoLoggingT :: (* -> *) -> * -> *) a :: * # Methods liftWith :: Monad m => (Run NoLoggingT -> m a) -> NoLoggingT m a # restoreT :: Monad m => m (StT NoLoggingT a) -> NoLoggingT m a #
MonadBaseControl b m => MonadBaseControl b (NoLoggingT m) # |
Associated Types type StM (NoLoggingT m :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase (NoLoggingT m) b -> b a) -> NoLoggingT m a # restoreM :: StM (NoLoggingT m) a -> NoLoggingT m a #
MonadBase b m => MonadBase b (NoLoggingT m) # |
Methods liftBase :: b α -> NoLoggingT m α #
MonadError e m => MonadError e (NoLoggingT m) # |
Methods throwError :: e -> NoLoggingT m a # catchError :: NoLoggingT m a -> (e -> NoLoggingT m a) -> NoLoggingT m a #
MonadState s m => MonadState s (NoLoggingT m) # |
Methods get :: NoLoggingT m s # put :: s -> NoLoggingT m () # state :: (s -> (a, s)) -> NoLoggingT m a #
MonadWriter w m => MonadWriter w (NoLoggingT m) # |
Methods writer :: (a, w) -> NoLoggingT m a # tell :: w -> NoLoggingT m () # listen :: NoLoggingT m a -> NoLoggingT m (a, w) # pass :: NoLoggingT m (a, w -> w) -> NoLoggingT m a #
Monad m => Monad (NoLoggingT m) # |
Methods (>>=) :: NoLoggingT m a -> (a -> NoLoggingT m b) -> NoLoggingT m b # (>>) :: NoLoggingT m a -> NoLoggingT m b -> NoLoggingT m b # return :: a -> NoLoggingT m a # fail :: String -> NoLoggingT m a #
Monad m => Functor (NoLoggingT m) # |
Methods fmap :: (a -> b) -> NoLoggingT m a -> NoLoggingT m b # (<$) :: a -> NoLoggingT m b -> NoLoggingT m a #
Monad m => Applicative (NoLoggingT m) # |
Methods pure :: a -> NoLoggingT m a # (<*>) :: NoLoggingT m (a -> b) -> NoLoggingT m a -> NoLoggingT m b # (*>) :: NoLoggingT m a -> NoLoggingT m b -> NoLoggingT m b # (<*) :: NoLoggingT m a -> NoLoggingT m b -> NoLoggingT m a #
MonadIO m => MonadIO (NoLoggingT m) # |
Methods liftIO :: IO a -> NoLoggingT m a #
MonadActive m => MonadActive (NoLoggingT m) # |
Methods monadActive :: NoLoggingT m Bool #
MonadThrow m => MonadThrow (NoLoggingT m) # |
Methods throwM :: Exception e => e -> NoLoggingT m a #
MonadCatch m => MonadCatch (NoLoggingT m) # |
Methods catch :: Exception e => NoLoggingT m a -> (e -> NoLoggingT m a) -> NoLoggingT m a #
MonadMask m => MonadMask (NoLoggingT m) # |
Methods mask :: ((forall a. NoLoggingT m a -> NoLoggingT m a) -> NoLoggingT m b) -> NoLoggingT m b # uninterruptibleMask :: ((forall a. NoLoggingT m a -> NoLoggingT m a) -> NoLoggingT m b) -> NoLoggingT m b #
MonadResource m => MonadResource (NoLoggingT m) # |
Methods liftResourceT :: ResourceT IO a -> NoLoggingT m a #
MonadIO m => MonadLoggerIO (NoLoggingT m) # |
Methods askLoggerIO :: NoLoggingT m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #
Monad m => MonadLogger (NoLoggingT m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> NoLoggingT m () #
type StT NoLoggingT a # |
type StT NoLoggingT a = a
type StM (NoLoggingT m) a # |
type StM (NoLoggingT m) a = StM m a

# TH logging

logDebug :: Q Exp #

Generates a function that takes a `Text` and logs a `LevelDebug` message. Usage:

    $(logDebug) "This is a debug log message"

logInfo :: Q Exp #

See `logDebug`

logWarn :: Q Exp #

See `logDebug`

logError :: Q Exp #

See `logDebug`

logOther :: Text -> Q Exp #

Generates a function that takes a `Text` and logs a `LevelOther` message. Usage:

    $(logOther "My new level") "This is a log message"

# TH logging of showable values

logDebugSH :: Q Exp #

Generates a function that takes a 'Show a => a' and logs a `LevelDebug` message. Usage:

    $(logDebugSH) (Just "This is a debug log message")

Since: 0.3.18

logInfoSH :: Q Exp #

See `logDebugSH`

logWarnSH :: Q Exp #

See `logDebugSH`

logErrorSH :: Q Exp #

See `logDebugSH`

logOtherSH :: Text -> Q Exp #

Generates a function that takes a 'Show a => a' and logs a `LevelOther` message. Usage:

    $(logOtherSH "My new level") "This is a log message"

# TH logging with source

logDebugS :: Q Exp #

Generates a function that takes a `LogSource` and `Text` and logs a `LevelDebug` message. Usage:

    $logDebugS "SomeSource" "This is a debug log message"

logInfoS :: Q Exp #

See `logDebugS`

logWarnS :: Q Exp #

See `logDebugS`

logErrorS :: Q Exp #

See `logDebugS`

logOtherS :: Q Exp #

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

liftLoc :: Loc -> Q Exp #

Lift a location into an Exp.

Since 0.3.1

# Non-TH logging

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 () #

# Non-TH logging with source

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 () #

# Callstack logging

logDebugCS :: MonadLogger m => CallStack -> Text -> m () #

Logs a message with location given by `CallStack`. See `CallStack` for more convenient functions for `CallStack` based logging.

Since: 0.3.19

logInfoCS :: MonadLogger m => CallStack -> Text -> m () #

See `logDebugCS`

Since: 0.3.19

logWarnCS :: MonadLogger m => CallStack -> Text -> m () #

See `logDebugCS`

Since: 0.3.19

logErrorCS :: MonadLogger m => CallStack -> Text -> m () #

See `logDebugCS`

Since: 0.3.19

logOtherCS :: MonadLogger m => CallStack -> LogLevel -> Text -> m () #

See `logDebugCS`

Since: 0.3.19

# utilities for defining your own loggers

defaultLogStr :: Loc -> LogSource -> LogLevel -> LogStr -> LogStr #

data Loc :: * #

Constructors

Loc |
Fields loc_filename :: String loc_package :: String loc_module :: String loc_start :: CharPos loc_end :: CharPos

Instances

Eq Loc |
Methods (==) :: Loc -> Loc -> Bool # (/=) :: Loc -> Loc -> Bool #
Data Loc |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Loc -> c Loc # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Loc # toConstr :: Loc -> Constr # dataTypeOf :: Loc -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Loc) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Loc) # gmapT :: (forall b. Data b => b -> b) -> Loc -> Loc # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Loc -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Loc -> r # gmapQ :: (forall d. Data d => d -> u) -> Loc -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Loc -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Loc -> m Loc # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Loc -> m Loc # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Loc -> m Loc #
Ord Loc |
Methods compare :: Loc -> Loc -> Ordering # (<) :: Loc -> Loc -> Bool # (<=) :: Loc -> Loc -> Bool # (>) :: Loc -> Loc -> Bool # (>=) :: Loc -> Loc -> Bool # max :: Loc -> Loc -> Loc # min :: Loc -> Loc -> Loc #
Show Loc |
Methods showsPrec :: Int -> Loc -> ShowS # show :: Loc -> String # showList :: [Loc] -> ShowS #
Generic Loc |
Associated Types type Rep Loc :: * -> * # Methods from :: Loc -> Rep Loc x # to :: Rep Loc x -> Loc #
type Rep Loc |
type Rep Loc = D1 (MetaData "Loc" "Language.Haskell.TH.Syntax" "template-haskell" False) (C1 (MetaCons "Loc" PrefixI True) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "loc_filename") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)) (S1 (MetaSel (Just Symbol "loc_package") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String))) ((:*:) (S1 (MetaSel (Just Symbol "loc_module") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)) ((:*:) (S1 (MetaSel (Just Symbol "loc_start") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 CharPos)) (S1 (MetaSel (Just Symbol "loc_end") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 CharPos))))))