on master help sign in
Merge pull request #86 from reactormonk/ask-logger-io

Implemented askLoggerIO

commit10f69b947d9cd28e9dff695c8f88113c96e65415 authorMichael Xavier <michael@michaelxavier.net> dateThu 15 Mar 2018, 11:51 (9 years ago) parent63be227bd7f084
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)