monad-logger-0.3.39: A class of monads which can log messages.
Safe Haskell Trustworthy
Language Haskell2010

Control.Monad.Logger

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 HandlerT 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

MonadLogger

class Monad m => MonadLogger m where Source #

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

Minimal complete definition

Nothing

Instances

Instances details
MonadLogger m => MonadLogger ( MaybeT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadLogger m => MonadLogger ( ResourceT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadLogger m => MonadLogger ( ListT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadIO m => MonadLogger ( LoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

Monad m => MonadLogger ( WriterLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

Monad m => MonadLogger ( NoLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

( MonadLogger m, Monoid w) => MonadLogger ( WriterT w m) Source #
Instance details

Defined in Control.Monad.Logger

( MonadLogger m, Monoid w) => MonadLogger ( WriterT w m) Source #
Instance details

Defined in Control.Monad.Logger

MonadLogger m => MonadLogger ( StateT s m) Source #
Instance details

Defined in Control.Monad.Logger

MonadLogger m => MonadLogger ( StateT s m) Source #
Instance details

Defined in Control.Monad.Logger

MonadLogger m => MonadLogger ( ReaderT r m) Source #
Instance details

Defined in Control.Monad.Logger

MonadLogger m => MonadLogger ( ExceptT e m) Source #
Instance details

Defined in Control.Monad.Logger

( MonadLogger m, Error e) => MonadLogger ( ErrorT e m) Source #
Instance details

Defined in Control.Monad.Logger

MonadLogger m => MonadLogger ( IdentityT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadLogger m => MonadLogger ( ConduitM i o m) Source #
Instance details

Defined in Control.Monad.Logger

MonadLogger m => MonadLogger ( ContT r m) Source #
Instance details

Defined in Control.Monad.Logger

( MonadLogger m, Monoid w) => MonadLogger ( RWST r w s m) Source #
Instance details

Defined in Control.Monad.Logger

( MonadLogger m, Monoid w) => MonadLogger ( RWST r w s m) Source #
Instance details

Defined in Control.Monad.Logger

MonadLogger m => MonadLogger ( Pipe l i o u m) Source #
Instance details

Defined in Control.Monad.Logger

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

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

Minimal complete definition

Nothing

Methods

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

Request the logging function itself.

Since: 0.3.10

Instances

Instances details
MonadLoggerIO m => MonadLoggerIO ( MaybeT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadLoggerIO m => MonadLoggerIO ( ResourceT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadLoggerIO m => MonadLoggerIO ( ListT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadIO m => MonadLoggerIO ( LoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadIO m => MonadLoggerIO ( NoLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

( MonadLoggerIO m, Monoid w) => MonadLoggerIO ( WriterT w m) Source #
Instance details

Defined in Control.Monad.Logger

( MonadLoggerIO m, Monoid w) => MonadLoggerIO ( WriterT w m) Source #
Instance details

Defined in Control.Monad.Logger

MonadLoggerIO m => MonadLoggerIO ( StateT s m) Source #
Instance details

Defined in Control.Monad.Logger

MonadLoggerIO m => MonadLoggerIO ( StateT s m) Source #
Instance details

Defined in Control.Monad.Logger

MonadLoggerIO m => MonadLoggerIO ( ReaderT r m) Source #
Instance details

Defined in Control.Monad.Logger

MonadLoggerIO m => MonadLoggerIO ( ExceptT e m) Source #
Instance details

Defined in Control.Monad.Logger

( MonadLoggerIO m, Error e) => MonadLoggerIO ( ErrorT e m) Source #
Instance details

Defined in Control.Monad.Logger

MonadLoggerIO m => MonadLoggerIO ( IdentityT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadLoggerIO m => MonadLoggerIO ( ConduitM i o m) Source #
Instance details

Defined in Control.Monad.Logger

MonadLoggerIO m => MonadLoggerIO ( ContT r m) Source #
Instance details

Defined in Control.Monad.Logger

( MonadLoggerIO m, Monoid w) => MonadLoggerIO ( RWST r w s m) Source #
Instance details

Defined in Control.Monad.Logger

( MonadLoggerIO m, Monoid w) => MonadLoggerIO ( RWST r w s m) Source #
Instance details

Defined in Control.Monad.Logger

MonadLoggerIO m => MonadLoggerIO ( Pipe l i o u m) Source #
Instance details

Defined in Control.Monad.Logger

Re-export from fast-logger

class ToLogStr msg where Source #

Types that can be converted to a LogStr . Instances for types from the text library use a UTF-8 encoding. Instances for numerical types use a decimal encoding.

Instances

Instances details
ToLogStr Double

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Float

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Int

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Int8

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Int16

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Int32

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Int64

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Integer

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Word

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Word8

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Word16

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Word32

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Word64

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr ByteString
Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr ByteString
Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Text
Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Text
Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr String
Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr ShortByteString
Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Builder
Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr LogStr
Instance details

Defined in System.Log.FastLogger.LogStr

Helper transformers

newtype LoggingT m a Source #

Monad transformer that adds a new logging function.

Since: 0.2.2

Constructors

LoggingT

Instances

Instances details
MonadTrans LoggingT Source #
Instance details

Defined in Control.Monad.Logger

Methods

lift :: Monad m => m a -> LoggingT m a Source #

MonadTransControl LoggingT Source #
Instance details

Defined in Control.Monad.Logger

Associated Types

type StT LoggingT a Source #

MonadRWS r w s m => MonadRWS r w s ( LoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadBase b m => MonadBase b ( LoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

Methods

liftBase :: b α -> LoggingT m α Source #

MonadBaseControl b m => MonadBaseControl b ( LoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

Associated Types

type StM ( LoggingT m) a Source #

MonadWriter w m => MonadWriter w ( LoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadState s m => MonadState s ( LoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadReader r m => MonadReader r ( LoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadError e m => MonadError e ( LoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

Monad m => Monad ( LoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

Functor m => Functor ( LoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadFail m => MonadFail ( LoggingT m) Source #

Since: 0.3.30

Instance details

Defined in Control.Monad.Logger

Applicative m => Applicative ( LoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadIO m => MonadIO ( LoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadUnliftIO m => MonadUnliftIO ( LoggingT m) Source #

Since: 0.3.26

Instance details

Defined in Control.Monad.Logger

Methods

withRunInIO :: (( forall a. LoggingT m a -> IO a) -> IO b) -> LoggingT m b Source #

MonadResource m => MonadResource ( LoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadThrow m => MonadThrow ( LoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadActive m => MonadActive ( LoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadCatch m => MonadCatch ( LoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadMask m => MonadMask ( LoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadCont m => MonadCont ( LoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

Methods

callCC :: ((a -> LoggingT m b) -> LoggingT m a) -> LoggingT m a Source #

MonadIO m => MonadLoggerIO ( LoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadIO m => MonadLogger ( LoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

( Applicative m, Semigroup a) => Semigroup ( LoggingT m a) Source #
Instance details

Defined in Control.Monad.Logger

( Applicative m, Monoid a) => Monoid ( LoggingT m a) Source #
Instance details

Defined in Control.Monad.Logger

type StT LoggingT a Source #
Instance details

Defined in Control.Monad.Logger

type StT LoggingT a = a
type StM ( LoggingT m) a Source #
Instance details

Defined in Control.Monad.Logger

type StM ( LoggingT m) a = StM m a

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

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

Since: 0.2.2

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

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

Since: 0.2.2

runChanLoggingT :: MonadIO m => Chan LogLine -> LoggingT m a -> m a Source #

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

runFileLoggingT :: MonadBaseControl IO m => FilePath -> LoggingT m a -> m a Source #

Run a block using a MonadLogger instance which appends to the specified file.

Since: 0.3.22

unChanLoggingT :: ( MonadLogger m, MonadIO m) => Chan LogLine -> m void Source #

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 Source #

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 Source #

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 Source #

Monad transformer that disables logging.

Since: 0.2.4

Constructors

NoLoggingT

Fields

Instances

Instances details
MonadTrans NoLoggingT Source #
Instance details

Defined in Control.Monad.Logger

MonadTransControl NoLoggingT Source #
Instance details

Defined in Control.Monad.Logger

Associated Types

type StT NoLoggingT a Source #

MonadBase b m => MonadBase b ( NoLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

Methods

liftBase :: b α -> NoLoggingT m α Source #

MonadBaseControl b m => MonadBaseControl b ( NoLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

Associated Types

type StM ( NoLoggingT m) a Source #

MonadWriter w m => MonadWriter w ( NoLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadState s m => MonadState s ( NoLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadReader r m => MonadReader r ( NoLoggingT m) Source #

Since: 0.3.24

Instance details

Defined in Control.Monad.Logger

MonadError e m => MonadError e ( NoLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

Monad m => Monad ( NoLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

Functor m => Functor ( NoLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadFail m => MonadFail ( NoLoggingT m) Source #

Since: 0.3.30

Instance details

Defined in Control.Monad.Logger

Applicative m => Applicative ( NoLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadIO m => MonadIO ( NoLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadUnliftIO m => MonadUnliftIO ( NoLoggingT m) Source #

Since: 0.3.26

Instance details

Defined in Control.Monad.Logger

Methods

withRunInIO :: (( forall a. NoLoggingT m a -> IO a) -> IO b) -> NoLoggingT m b Source #

MonadResource m => MonadResource ( NoLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadThrow m => MonadThrow ( NoLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadActive m => MonadActive ( NoLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadCatch m => MonadCatch ( NoLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadMask m => MonadMask ( NoLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadIO m => MonadLoggerIO ( NoLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

Monad m => MonadLogger ( NoLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

( Applicative m, Semigroup a) => Semigroup ( NoLoggingT m a) Source #
Instance details

Defined in Control.Monad.Logger

( Applicative m, Monoid a) => Monoid ( NoLoggingT m a) Source #
Instance details

Defined in Control.Monad.Logger

type StT NoLoggingT a Source #
Instance details

Defined in Control.Monad.Logger

type StM ( NoLoggingT m) a Source #
Instance details

Defined in Control.Monad.Logger

type StM ( NoLoggingT m) a = StM m a

mapNoLoggingT :: (m a -> n b) -> NoLoggingT m a -> NoLoggingT n b Source #

Map the unwrapped computation using the given function.

Since: 0.3.29

newtype WriterLoggingT m a Source #

Since: 0.3.28

Constructors

WriterLoggingT

Fields

Instances

Instances details
MonadTrans WriterLoggingT Source #
Instance details

Defined in Control.Monad.Logger

MonadTransControl WriterLoggingT Source #
Instance details

Defined in Control.Monad.Logger

MonadBase b m => MonadBase b ( WriterLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

Methods

liftBase :: b α -> WriterLoggingT m α Source #

MonadBaseControl b m => MonadBaseControl b ( WriterLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

Associated Types

type StM ( WriterLoggingT m) a Source #

Monad m => Monad ( WriterLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

Functor m => Functor ( WriterLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

Applicative m => Applicative ( WriterLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadIO m => MonadIO ( WriterLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadThrow m => MonadThrow ( WriterLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadCatch m => MonadCatch ( WriterLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

MonadMask m => MonadMask ( WriterLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

Monad m => MonadLogger ( WriterLoggingT m) Source #
Instance details

Defined in Control.Monad.Logger

( Applicative m, Semigroup a) => Semigroup ( WriterLoggingT m a) Source #
Instance details

Defined in Control.Monad.Logger

( Applicative m, Monoid a) => Monoid ( WriterLoggingT m a) Source #
Instance details

Defined in Control.Monad.Logger

type StT WriterLoggingT a Source #
Instance details

Defined in Control.Monad.Logger

type StM ( WriterLoggingT m) a Source #
Instance details

Defined in Control.Monad.Logger

execWriterLoggingT :: Functor m => WriterLoggingT m a -> m [ LogLine ] Source #

Run a block using a MonadLogger instance. Return logs in a list | @since 0.3.28

runWriterLoggingT :: Functor m => WriterLoggingT m a -> m (a, [ LogLine ]) Source #

Run a block using a MonadLogger instance. Return a value and logs in a list | @since 0.3.28

mapLoggingT :: (m a -> n b) -> LoggingT m a -> LoggingT n b Source #

Map the unwrapped computation using the given function.

Since: 0.3.29

TH logging

logDebug :: Q Exp Source #

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

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

logOther :: Text -> Q Exp Source #

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 Source #

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

logOtherSH :: Text -> Q Exp Source #

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 Source #

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

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

logOtherS :: Q Exp Source #

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 Source #

Lift a location into an Exp.

Since: 0.3.1

Non-TH logging

Non-TH logging with source

Callstack logging

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

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

Since: 0.3.19

utilities for defining your own loggers

Loc

When monad-logger is compiled with the template_haskell flag set to true (the default), the Loc below is a re-export from the template-haskell package. When the flag is false, the Loc below is a copy of that data structure defined in monad-logger itself.

If you are making a library that:

  • Uses monad-logger
  • Uses Loc in a type signature
  • But doesn't need to depend on template-haskell for other reasons

You can import Loc directly from this package, instead of adding an dependency on template-haskell and importing from there. This allows users to compile your package in environments that don't support template-haskell .

data Loc Source #

Instances

Instances details
Eq Loc
Instance details

Defined in Language.Haskell.TH.Syntax

Data Loc
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

gfoldl :: ( forall d b. Data d => c (d -> b) -> d -> c b) -> ( forall g. g -> c g) -> Loc -> c Loc Source #

gunfold :: ( forall b r. Data b => c (b -> r) -> c r) -> ( forall r. r -> c r) -> Constr -> c Loc Source #

toConstr :: Loc -> Constr Source #

dataTypeOf :: Loc -> DataType Source #

dataCast1 :: Typeable t => ( forall d. Data d => c (t d)) -> Maybe (c Loc ) Source #

dataCast2 :: Typeable t => ( forall d e. ( Data d, Data e) => c (t d e)) -> Maybe (c Loc ) Source #

gmapT :: ( forall b. Data b => b -> b) -> Loc -> Loc Source #

gmapQl :: (r -> r' -> r) -> r -> ( forall d. Data d => d -> r') -> Loc -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> ( forall d. Data d => d -> r') -> Loc -> r Source #

gmapQ :: ( forall d. Data d => d -> u) -> Loc -> [u] Source #

gmapQi :: Int -> ( forall d. Data d => d -> u) -> Loc -> u Source #

gmapM :: Monad m => ( forall d. Data d => d -> m d) -> Loc -> m Loc Source #

gmapMp :: MonadPlus m => ( forall d. Data d => d -> m d) -> Loc -> m Loc Source #

gmapMo :: MonadPlus m => ( forall d. Data d => d -> m d) -> Loc -> m Loc Source #

Ord Loc
Instance details

Defined in Language.Haskell.TH.Syntax

Show Loc
Instance details

Defined in Language.Haskell.TH.Syntax

Generic Loc
Instance details

Defined in Language.Haskell.TH.Syntax

Associated Types

type Rep Loc :: Type -> Type Source #

type Rep Loc
Instance details

Defined in Language.Haskell.TH.Syntax

defaultLoc :: Loc Source #

dummy location, used with logWithoutLoc

Since: 0.3.23

defaultOutput :: Handle -> Loc -> LogSource -> LogLevel -> LogStr -> IO () Source #

A default implementation of monadLoggerLog that accepts a file handle as the first argument.

This is used in the definition of runStdoutLoggingT :

runStdoutLoggingT :: MonadIO m => LoggingT m a -> m a
runStdoutLoggingT action =
    runLoggingT action (defaultOutput stdout)

Since: 0.3.36