on master help sign in
Merge pull request #111 from vlatkoB/master
737e10bMichael Xavier
katip/changelog.md+5
@@ -1,3 +1,8 @@
1+0.8.3.0
2+=======
3+
4+* Add `logKatipItem` function and reimplement `logItem` to use it. [vlatkoB](https://github.com/vlatkoB)
5+
10.8.2.0
60.8.2.0
2=======
7=======
3* Add `MonadFail` instances for `base` >= 4.9.0.0 [Koray Al](https://github.com/korayal)
8* Add `MonadFail` instances for `base` >= 4.9.0.0 [Koray Al](https://github.com/korayal)
katip/katip.cabal+1−1
@@ -1,5 +1,5 @@
1name: katip
1name: katip
2−version: 0.8.2.0
2+version: 0.8.3.0
3synopsis: A structured logging framework.
3synopsis: A structured logging framework.
4description:
4description:
5 Katip is a structured logging framework. See README.md for more details.
5 Katip is a structured logging framework. See README.md for more details.
katip/src/Katip.hs+1
@@ -161,6 +161,7 @@ module Katip
161 , logT
161 , logT
162 , logLoc
162 , logLoc
163 , logItem
163 , logItem
164+ , logKatipItem
164 , logException
165 , logException
165 -- ** 'KatipContext': Logging With Context
166 -- ** 'KatipContext': Logging With Context
166 -- $katipcontextlogging
167 -- $katipcontextlogging
katip/src/Katip/Core.hs+23−13
@@ -941,19 +941,29 @@ logItem
941 -> m ()
941 -> m ()
942logItem a ns loc sev msg = do
942logItem a ns loc sev msg = do
943 LogEnv{..} <- getLogEnv
943 LogEnv{..} <- getLogEnv
944− liftIO $ do
944+ logKatipItem =<< liftIO
945− item <- Item
946− <$> pure _logEnvApp
945+ (Item <$> pure _logEnvApp
947− <*> pure _logEnvEnv
946+ <*> pure _logEnvEnv
948− <*> pure sev
947+ <*> pure sev
949− <*> (mkThreadIdText <$> myThreadId)
948+ <*> (mkThreadIdText <$> myThreadId)
950− <*> pure _logEnvHost
949+ <*> pure _logEnvHost
951− <*> pure _logEnvPid
950+ <*> pure _logEnvPid
952− <*> pure a
951+ <*> pure a
953− <*> pure msg
952+ <*> pure msg
954− <*> _logEnvTimer
953+ <*> _logEnvTimer
955− <*> pure (_logEnvApp <> ns)
954+ <*> pure (_logEnvApp <> ns)
956− <*> pure loc
955+ <*> pure loc)
956+
957+-- | Log already constructed 'Item'. This is the lowest level function that other log*
958+-- functions use.
959+-- It can be useful when implementing centralised logging services.
960+logKatipItem
961+ :: (A.Applicative m, LogItem a, Katip m)
962+ => Item a
963+ -> m ()
964+logKatipItem item = do
965+ LogEnv{..} <- getLogEnv
966+ liftIO $
957 FT.forM_ (M.elems _logEnvScribes) $ \ ScribeHandle {..} -> do
967 FT.forM_ (M.elems _logEnvScribes) $ \ ScribeHandle {..} -> do
958 whenM (scribePermitItem shScribe item) $
968 whenM (scribePermitItem shScribe item) $
959 void $ atomically (tryWriteTBQueue shChan (NewItem item))
969 void $ atomically (tryWriteTBQueue shChan (NewItem item))