on master help sign in
Implemented askLoggerIO
commitbd7f08415db1df53aa1e67261d2ce3b05d66fc95 authorSimon Hafner <hafnersimon@gmail.com> dateTue 13 Mar 2018, 16:40 (9 years ago) parentc14b93c
1 file changed+8
katip/src/Katip/Monadic.hs+8
katip/src/Katip/Monadic.hs+8
@@ -35,6 +35,7 @@ module Katip.Monadic
3535 , katipAddContext
3636 , KatipContextTState(..)
3737 , NoLoggingT
38+ , askLoggerIO
3839 ) where
3940
4041
@@ -486,3 +487,10 @@ instance MonadIO m => KatipContext (NoLoggingT m) where
486487 localKatipContext = const id
487488 getKatipNamespace = pure mempty
488489 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)