logFM :: (Applicative m, KatipContext m)=> SeveritySeverity of the message
-> LogStrThe log message
-> m ()
Log with full context, but without any code location. Automatically supplies payload and namespace.
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
Modulekatip-0.8.8.0Haskell2010
Provides support for treating payloads and namespaces as composable contexts. The common pattern would be to provide a KatipContext instance for your base monad.
logFM :: (Applicative m, KatipContext m)=> SeveritySeverity of the message
-> LogStrThe log message
-> m ()Log with full context, but without any code location. Automatically supplies payload and namespace.
Loc-tagged logging when using template-haskell. Automatically supplies payload and namespace.
$(logTM) InfoS "Hello world"Loc-tagged logging when using getCallStack implicit-callstacks>. Automatically supplies payload and namespace.
Same consideration as logLoc applies.
By default, location will be logged from the module that invokes logLocM. If you want to use logLocM in a helper, wrap the entire helper in withFrozenCallStack to retain the callsite of the helper in the logs.
This function does not require template-haskell. Using GHC <= 7.8 will result in the emission of a log line without any location information. Users using GHC <= 7.8 may want to use the template-haskell function logTM for maximum compatibility.
logLocM InfoS "Hello world"Log with everything, including a source code location. This is very low level and you typically can use logTM in its place. Automatically supplies payload and namespace.
logExceptionM :: (KatipContext m, MonadCatch m, Applicative m)=> m aMain action to run
-> SeveritySeverity
-> m aPerform an action while logging any exceptions that may occur.
Inspired by onException.
> error "foo" `logExceptionM` ErrorSA monadic context that has an inherant way to get logging context
and namespace. Examples include a web application monad or database
monad. The local variants are just like local from Reader and
indeed you can easily implement them with local if you happen to
be using a Reader in your monad. These give us katipAddNamespace
and katipAddContext that works with *any* KatipContext, as
opposed to making users have to implement these functions on their
own in each app.
getKatipContext :: m LogContextslocalKatipContext :: (LogContexts -> LogContexts) -> m a -> m aTemporarily modify the current context for the duration of the supplied monad. Used in katipAddContext
getKatipNamespace :: m NamespacelocalKatipNamespace :: (Namespace -> Namespace) -> m a -> m aTemporarily modify the current namespace for the duration of the supplied monad. Used in katipAddNamespace
MonadIO m => KatipContext (KatipContextT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadIO m => KatipContext (NoLoggingT m)Defined in katip-0.8.8.0 · Katip.Monadic(Monad m, KatipContext m) => KatipContext (KatipT m)Defined in katip-0.8.8.0 · Katip.Monadic(KatipContext m, Katip (ResourceT m)) => KatipContext (ResourceT m)Defined in katip-0.8.8.0 · Katip.Monadic(KatipContext m, Katip (MaybeT m)) => KatipContext (MaybeT m)Defined in katip-0.8.8.0 · Katip.Monadic(Monoid w, KatipContext m, Katip (WriterT w m)) => KatipContext (WriterT w m)Defined in katip-0.8.8.0 · Katip.Monadic(Monoid w, KatipContext m, Katip (WriterT w m)) => KatipContext (WriterT w m)Defined in katip-0.8.8.0 · Katip.Monadic(KatipContext m, Katip (ExceptT e m)) => KatipContext (ExceptT e m)Defined in katip-0.8.8.0 · Katip.Monadic(KatipContext m, Katip (IdentityT m)) => KatipContext (IdentityT m)Defined in katip-0.8.8.0 · Katip.Monadic(KatipContext m, Katip (ReaderT r m)) => KatipContext (ReaderT r m)Defined in katip-0.8.8.0 · Katip.Monadic(KatipContext m, Katip (StateT s m)) => KatipContext (StateT s m)Defined in katip-0.8.8.0 · Katip.Monadic(KatipContext m, Katip (StateT s m)) => KatipContext (StateT s m)Defined in katip-0.8.8.0 · Katip.Monadic(Monoid w, KatipContext m, Katip (RWST r w s m)) => KatipContext (RWST r w s m)Defined in katip-0.8.8.0 · Katip.Monadic(Monoid w, KatipContext m, Katip (RWST r w s m)) => KatipContext (RWST r w s m)Defined in katip-0.8.8.0 · Katip.MonadicA wrapper around a log context that erases type information so that contexts from multiple layers can be combined intelligently.
Heterogeneous list of log contexts that provides a smart
LogContext instance for combining multiple payload policies. This
is critical for log contexts deep down in a stack to be able to
inject their own context without worrying about other context that
has already been set. Also note that contexts are treated as a
sequence and <> will be appended to the right hand side of the
sequence. If there are conflicting keys in the contexts, the /right
side will take precedence/, which is counter to how monoid works
for Map and HashMap, so bear that in mind. The reasoning is
that if the user is sequentially adding contexts to the right
side of the sequence, on conflict the intent is to overwrite with
the newer value (i.e. the rightmost value).
Additional note: you should not mappend LogContexts in any sort of infinite loop, as it retains all data, so that would be a memory leak.
Semigroup LogContextsDefined in katip-0.8.8.0 · Katip.MonadicMonoid LogContextsDefined in katip-0.8.8.0 · Katip.MonadicToJSON LogContextsDefined in katip-0.8.8.0 · Katip.MonadicLogItem LogContextsDefined in katip-0.8.8.0 · Katip.MonadicToObject LogContextsDefined in katip-0.8.8.0 · Katip.MonadicLift a log context into the generic wrapper so that it can combine with the existing log context.
Provides a simple transformer that defines a KatipContext instance for a fixed namespace and context. Just like KatipT, you should use this if you prefer an explicit transformer stack and don't want to (or cannot) define KatipContext for your monad . This is the slightly more powerful version of KatipT in that it provides KatipContext instead of just Katip. For instance:
threadWithLogging = do
le <- getLogEnv
ctx <- getKatipContext
ns <- getKatipNamespace
forkIO $ runKatipContextT le ctx ns $ do
$(logTM) InfoS "Look, I can log in IO and retain context!"
doOtherStuff
MonadTrans KatipContextTDefined in katip-0.8.8.0 · Katip.MonadicMonadTransControl KatipContextTDefined in katip-0.8.8.0 · Katip.MonadicMonadError e m => MonadError e (KatipContextT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadReader r m => MonadReader r (KatipContextT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadState s m => MonadState s (KatipContextT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadWriter w m => MonadWriter w (KatipContextT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadBase b m => MonadBase b (KatipContextT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadBaseControl b m => MonadBaseControl b (KatipContextT m)Defined in katip-0.8.8.0 · Katip.MonadicMonad m => Monad (KatipContextT m)Defined in katip-0.8.8.0 · Katip.MonadicFunctor m => Functor (KatipContextT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadFix m => MonadFix (KatipContextT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadFail m => MonadFail (KatipContextT m)Defined in katip-0.8.8.0 · Katip.MonadicApplicative m => Applicative (KatipContextT m)Defined in katip-0.8.8.0 · Katip.MonadicAlternative m => Alternative (KatipContextT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadPlus m => MonadPlus (KatipContextT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadIO m => MonadIO (KatipContextT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadCatch m => MonadCatch (KatipContextT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadMask m => MonadMask (KatipContextT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadThrow m => MonadThrow (KatipContextT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadUnliftIO m => MonadUnliftIO (KatipContextT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadResource m => MonadResource (KatipContextT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadIO m => Katip (KatipContextT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadIO m => KatipContext (KatipContextT m)Defined in katip-0.8.8.0 · Katip.Monadictype StM (KatipContextT m) a = ComposeSt KatipContextT m aDefined in katip-0.8.8.0 · Katip.Monadictype StT KatipContextT a = StT (ReaderT KatipContextTState) aDefined in katip-0.8.8.0 · Katip.MonadicAppend a namespace segment to the current namespace for the given monadic action, then restore the previous state afterwards. Works with anything implementing KatipContext.
Append some context to the current context for the given monadic action, then restore the previous state afterwards. Important note: be careful using this in a loop. If you're using something like forever or replicateM_ that does explicit sharing to avoid a memory leak, youll be fine as it will *sequence* calls to katipAddNamespace, so each loop will get the same context added. If you instead roll your own recursion and you're recursing in the action you provide, you'll instead accumulate tons of redundant contexts and even if they all merge on log, they are stored in a sequence and will leak memory. Works with anything implementing KatipContext.
NoLoggingTrunNoLoggingT :: m aMonadTrans NoLoggingTDefined in katip-0.8.8.0 · Katip.MonadicMonadTransControl NoLoggingTDefined in katip-0.8.8.0 · Katip.MonadicMonadError e m => MonadError e (NoLoggingT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadReader r m => MonadReader r (NoLoggingT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadState s m => MonadState s (NoLoggingT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadWriter w m => MonadWriter w (NoLoggingT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadBase b m => MonadBase b (NoLoggingT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadBaseControl b m => MonadBaseControl b (NoLoggingT m)Defined in katip-0.8.8.0 · Katip.MonadicMonad m => Monad (NoLoggingT m)Defined in katip-0.8.8.0 · Katip.MonadicFunctor m => Functor (NoLoggingT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadFix m => MonadFix (NoLoggingT m)Defined in katip-0.8.8.0 · Katip.MonadicApplicative m => Applicative (NoLoggingT m)Defined in katip-0.8.8.0 · Katip.MonadicAlternative m => Alternative (NoLoggingT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadPlus m => MonadPlus (NoLoggingT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadIO m => MonadIO (NoLoggingT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadCatch m => MonadCatch (NoLoggingT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadMask m => MonadMask (NoLoggingT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadThrow m => MonadThrow (NoLoggingT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadUnliftIO m => MonadUnliftIO (NoLoggingT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadIO m => Katip (NoLoggingT m)Defined in katip-0.8.8.0 · Katip.MonadicMonadIO m => KatipContext (NoLoggingT m)Defined in katip-0.8.8.0 · Katip.Monadictype StM (NoLoggingT m) a = StM m aDefined in katip-0.8.8.0 · Katip.Monadictype StT NoLoggingT a = aDefined in katip-0.8.8.0 · Katip.MonadicConvenience function for when you have to integrate with a third party API that takes a generic logging function as an argument.