Provide the ability to log messages via MonadLog.
Instances2DispatchOf, StaticRep
type DispatchOf Log = 'Static 'WithSideEffectsDefined in log-effectful-1.0.0.0 · Effectful.Logdata StaticRep LogLog LoggerEnv
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
Provide the ability to log messages via MonadLog.
type DispatchOf Log = 'Static 'WithSideEffectsDefined in log-effectful-1.0.0.0 · Effectful.Logdata StaticRep LogLog LoggerEnvrunLog The state that every LogT carries around.
An object used for communication with a logger thread that outputs LogMessages using e.g. PostgreSQL, Elasticsearch or stdout (depending on the back-end chosen).
Available log levels.
Note that ordering in this definintion determines what the maximum log level is.
See Log.Monad.leMaxLogLevel.
Bounded LogLevelDefined in log-base-0.12.0.1 · Log.DataEq LogLevelDefined in log-base-0.12.0.1 · Log.DataOrd LogLevelDefined in log-base-0.12.0.1 · Log.DataShow LogLevelDefined in log-base-0.12.0.1 · Log.DataNFData LogLevelDefined in log-base-0.12.0.1 · Log.DataFromJSON LogLevelDefined in log-base-0.12.0.1 · Log.DataToJSON LogLevelDefined in log-base-0.12.0.1 · Log.DataRepresents the family of monads with logging capabilities. Each MonadLog carries with it some associated state (the logging environment) that can be modified locally with localData and localDomain.
logMessage :: LogLevel -> Text -> Value -> m ()Write a message to the log.
localData :: [Pair] -> m a -> m aExtend the additional data associated with each log message locally.
localDomain :: Text -> m a -> m aExtend the current application domain locally.
localMaxLogLevel :: LogLevel -> m a -> m aOverride the current maximum log level.
getLoggerEnv :: m LoggerEnvGet current LoggerEnv object. Useful for construction of logging
functions that work in a different monad, see getLoggerIO as an example.
Log :> es => MonadLog (Eff es)Defined in log-effectful-1.0.0.0 · Effectful.Log · orphanOrphan, canonical instance.
MonadBase IO m => MonadLog (LogT m)Defined in log-base-0.12.0.1 · Log.Monad(MonadLog m, Monad (t m), MonadTransControl t) => MonadLog (t m)Defined in log-base-0.12.0.1 · Log.ClassGeneric, overlapping instance.
Base implementation of logMessage for use with a specific LoggerEnv. Useful for reimplementation of MonadLog instance.
This is the simplest representation of UTC. It consists of the day number, and a time offset from midnight. Note that if a day has a leap second added to it, it will have 86401 seconds.
Eq UTCTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.UTCTimeData UTCTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.UTCTimeOrd UTCTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.UTCTimeRead UTCTimeDefined in time-1.12.2 · Data.Time.Format.Parse · orphanShow UTCTimeDefined in time-1.12.2 · Data.Time.LocalTime.Internal.ZonedTime · orphanGeneric UTCTimeDefined in time-compat-1.9.8 · Data.Time.Orphans · orphanNFData UTCTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.UTCTimeHashable UTCTimeDefined in time-compat-1.9.8 · Data.Time.Orphans · orphanFormatTime UTCTimeDefined in time-1.12.2 · Data.Time.Format.Format.Instances · orphanParseTime UTCTimeDefined in time-1.12.2 · Data.Time.Format.Parse.Instances · orphanISO8601 UTCTimeDefined in time-1.12.2 · Data.Time.Format.ISO8601yyyy-mm-ddThh:mm:ss[.sss]Z (ISO 8601:2004(E) sec. 4.3.2 extended format)
FromJSON UTCTimeDefined in aeson-2.2.3.0 · Data.Aeson.Types.FromJSONFromJSONKey UTCTimeDefined in aeson-2.2.3.0 · Data.Aeson.Types.FromJSONToJSON UTCTimeDefined in aeson-2.2.3.0 · Data.Aeson.Types.ToJSONToJSONKey UTCTimeDefined in aeson-2.2.3.0 · Data.Aeson.Types.ToJSONLift UTCTimeDefined in time-compat-1.9.8 · Data.Time.Orphans · orphantype Rep UTCTime = D1 ('MetaData "UTCTime"
"Data.Time.Clock.Internal.UTCTime"
"time-1.12.2-cfd2"
'False) (C1 ('MetaCons "UTCTime"
'PrefixI 'True) (S1 ('MetaSel ('Just "utctDay"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Day) :*: S1 ('MetaSel ('Just "utctDayTime"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DiffTime)))Defined in time-compat-1.9.8 · Data.Time.Orphans · orphanLog a message and its associated data using current time as the event time and the LogAttention log level.
Like logAttention, but without any additional associated data.
Log a message and its associated data using current time as the event time and the LogInfo log level.
Like logInfo, but without any additional associated data.
Log a message and its associated data using current time as the event time and the LogTrace log level.
Like logTrace, but without any additional associated data.
Represents message to be logged.
Eq LogMessageDefined in log-base-0.12.0.1 · Log.DataShow LogMessageDefined in log-base-0.12.0.1 · Log.DataNFData LogMessageDefined in log-base-0.12.0.1 · Log.DataFromJSON LogMessageDefined in log-base-0.12.0.1 · Log.DataToJSON LogMessageDefined in log-base-0.12.0.1 · Log.DataThe default log level. Returns LogInfo.
This function is partial.
showLogMessage :: Maybe UTCTimeThe time that message was added to the log.
-> LogMessageThe actual message.
-> TextRender a LogMessage to Text.
Execute logger to serialize a LogMessage.
Wait until all LogMessages stored in the internal queue are serialized.
Start an asynchronous logger thread that consumes all queued messages once per second.
Note: a bounded queue of size 1000000 is used internally to avoid unrestricted memory consumption.
To make sure that the messages get written out in the presence of exceptions,
use high-level wrappers like withLogger,
Log.Backend.ElasticSearch.withElasticSearchLogger or
withBulkStdOutLogger instead of this
function directly.
Note: some messages can be lost when the main thread shuts down without making sure that all logger threads have written out all messages, because in that case child threads are not given a chance to clean up by the RTS. This is apparently a feature: https://mail.haskell.org/pipermail/haskell-cafe/2014-February/112754.html
To work around this issue, make sure that the main thread doesn't
exit until all its children have terminated. The async package
makes this easy.
Problematic example:
import Control.Concurrent.Async
main :: IO ()
main = do
logger <- Log.Backend.ElasticSearch.elasticSearchLogger
a <- Control.Concurrent.Async.async (Log.Backend.ElasticSearch.withElasticSearchLogger $ \logger ->
runLogT "main" logger defaultLogLevel $ logTrace_ "foo")
-- Main thread exits without waiting for the child
-- to finish and without giving the child a chance
-- to do proper cleanup.
Fixed example:
import Control.Concurrent.Async
main :: IO ()
main = do
logger <- Log.Backend.ElasticSearch.elasticSearchLogger
a <- Control.Concurrent.Async.async (Log.Backend.ElasticSearch.withElasticSearchLogger $ \logger ->
runLogT "main" logger defaultLogLevel $ logTrace_ "foo")
Control.Concurrent.Async.wait a
-- Main thread waits for the child to finish, giving
-- it a chance to shut down properly. This works even
-- in the presence of exceptions in the child thread.
mkBulkLogger' Like mkBulkLogger, but with configurable queue size and thread delay.
Start a logger thread that consumes one queued message at a time.
Note: a bounded queue of size 1000000 is used internally to avoid unrestricted memory consumption.
Like mkBulkLogger, but with configurable queue size.
Monad transformer that adds logging capabilities to the underlying monad.
MonadTrans LogTDefined in log-base-0.12.0.1 · Log.MonadMonadTransControl LogTDefined in log-base-0.12.0.1 · Log.MonadMFunctor LogTDefined in log-base-0.12.0.1 · Log.MonadMonadError e m => MonadError e (LogT m)Defined in log-base-0.12.0.1 · Log.MonadMonadReader r m => MonadReader r (LogT m)Defined in log-base-0.12.0.1 · Log.MonadMonadState s m => MonadState s (LogT m)Defined in log-base-0.12.0.1 · Log.MonadMonadWriter w m => MonadWriter w (LogT m)Defined in log-base-0.12.0.1 · Log.MonadMonadBase b m => MonadBase b (LogT m)Defined in log-base-0.12.0.1 · Log.MonadMonadBaseControl b m => MonadBaseControl b (LogT m)Defined in log-base-0.12.0.1 · Log.MonadMonad m => Monad (LogT m)Defined in log-base-0.12.0.1 · Log.MonadFunctor m => Functor (LogT m)Defined in log-base-0.12.0.1 · Log.MonadMonadFail m => MonadFail (LogT m)Defined in log-base-0.12.0.1 · Log.MonadApplicative m => Applicative (LogT m)Defined in log-base-0.12.0.1 · Log.MonadAlternative m => Alternative (LogT m)Defined in log-base-0.12.0.1 · Log.MonadMonadPlus m => MonadPlus (LogT m)Defined in log-base-0.12.0.1 · Log.MonadMonadIO m => MonadIO (LogT m)Defined in log-base-0.12.0.1 · Log.MonadMonadCatch m => MonadCatch (LogT m)Defined in log-base-0.12.0.1 · Log.MonadMonadMask m => MonadMask (LogT m)Defined in log-base-0.12.0.1 · Log.MonadMonadThrow m => MonadThrow (LogT m)Defined in log-base-0.12.0.1 · Log.MonadMonadUnliftIO m => MonadUnliftIO (LogT m)Defined in log-base-0.12.0.1 · Log.MonadMonadBase IO m => MonadLog (LogT m)Defined in log-base-0.12.0.1 · Log.Monadtype StM (LogT m) a = ComposeSt LogT m aDefined in log-base-0.12.0.1 · Log.Monadtype StT LogT m = StT InnerLogT mDefined in log-base-0.12.0.1 · Log.MonadReturn an IO action that logs messages using the current MonadLog
context. Useful for interfacing with libraries such as aws or amazonka
that accept logging callbacks operating in IO.
Transform the computation inside a LogT.
runLogT