@@ -60,11 +60,11 @@ main = do
6060 -- use this to stack up various contextual details throughout your
6161 -- code and they will be flattened out and combined in the log
6262 -- output.
63− addNamespace "confrabulation" $ addContext (ConfrabLogCTX 42) $ do
63+ katipAddNamespace "confrabulation" $ katipAddContext (ConfrabLogCTX 42) $ do
6464 $(logTM) DebugS "Confrabulating widgets, with extra namespace and context"
6565 confrabulateWidgets
6666 $(logTM) InfoS "Namespace and context are back to normal"
67− noLogging $
67+ katipNoLogging $
6868 $(logTM) DebugS "You'll never see this log message!"
6969 -- This blocking call flushes all in-flight messages through
7070 -- handlers and then finalizes each scribe.
@@ -118,31 +118,14 @@ instance MonadBaseControl b m => MonadBaseControl b (MyStack m) where
118118
119119instance (MonadIO m) => Katip (MyStack m) where
120120 getLogEnv = view msLogEnv
121+ localLogEnv f (MyStack m) = MyStack (local (over msLogEnv f) m)
121122
122123
123124instance (MonadIO m) => KatipContext (MyStack m) where
124125 getKatipContext = view msKContext
126+ localKatipContext f (MyStack m) = MyStack (local (over msKContext f) m)
125127 getKatipNamespace = view msKNamespace
126−
127−
128−-------------------------------------------------------------------------------
129−-- | Merge some context into the log only for the given block
130−addContext :: (LogItem i, MonadReader r m, HasMyState r) => i -> m a -> m a
131−addContext i = local (\r -> r & msKContext <>~ ctxs)
132− where
133− ctxs = liftPayload i
134−
135−
136−-------------------------------------------------------------------------------
137−-- | Add a layer of namespace to the logs only for the given block
138−addNamespace :: (MonadReader r m, HasMyState r) => Namespace -> m a -> m a
139−addNamespace ns = local (\r -> r & msKNamespace <>~ ns)
140−
141−
142−-------------------------------------------------------------------------------
143−-- | Disable all log output temporarily
144−noLogging :: (MonadReader r m, HasMyState r) => m a -> m a
145−noLogging = local (\r -> r & msLogEnv %~ clearScribes)
128+ localKatipNamespace f (MyStack m) = MyStack (local (over msKNamespace f) m)
146129
147130
148131-------------------------------------------------------------------------------