on master help sign in
Merge pull request #86 from reactormonk/ask-logger-io
10f69b9Michael Xavier
katip/src/Katip/Monadic.hs+8
@@ -35,6 +35,7 @@ module Katip.Monadic
35 , katipAddContext
35 , katipAddContext
36 , KatipContextTState(..)
36 , KatipContextTState(..)
37 , NoLoggingT
37 , NoLoggingT
38+ , askLoggerIO
38 ) where
39 ) where
39
40
40
41
@@ -486,3 +487,10 @@ instance MonadIO m => KatipContext (NoLoggingT m) where
486 localKatipContext = const id
487 localKatipContext = const id
487 getKatipNamespace = pure mempty
488 getKatipNamespace = pure mempty
488 localKatipNamespace = const id
489 localKatipNamespace = const id
490+
491+askLoggerIO :: (Applicative m, KatipContext m) => m (Severity -> LogStr -> IO ())
492+askLoggerIO = do
493+ ctx <- getKatipContext
494+ ns <- getKatipNamespace
495+ logEnv <- getLogEnv
496+ pure (\sev msg -> runKatipT logEnv $ logF ctx ns sev msg)