@@ -44,8 +44,7 @@ import Control.Monad.Trans.Either
4444import Control.Monad.Trans.Except
4545import Control.Monad.Trans.Maybe
4646import Control.Monad.Trans.Reader
47−import Control.Monad.Trans.Resource (MonadResource, ResourceT,
48− transResourceT)
47+import Control.Monad.Trans.Resource (ResourceT, transResourceT)
4948import Control.Monad.Trans.RWS.Lazy (RWST, mapRWST)
5049import qualified Control.Monad.Trans.RWS.Strict as Strict (RWST, mapRWST)
5150import Control.Monad.Trans.State.Lazy (StateT, mapStateT)
@@ -665,7 +664,7 @@ makeLenses ''LogEnv
665664
666665
667666-------------------------------------------------------------------------------
668−-- | Create a reasonable default InitLogEnv. Uses an 'AutoUpdate' which
667+-- | Create a reasonable default InitLogEnv. Uses an 'AutoUdate' which
669668-- updates the timer every 1ms. If you need even more timestamp
670669-- precision at the cost of performance, consider setting
671670-- '_logEnvTimer' with 'getCurrentTime'.
@@ -880,8 +879,7 @@ instance (Katip m) => Katip (ResourceT m) where
880879-- opposed to implementing 'Katip' for your monad.
881880newtype KatipT m a = KatipT { unKatipT :: ReaderT LogEnv m a }
882881 deriving ( Functor, Applicative, Monad, MonadIO
883− , MonadMask, MonadCatch, MonadThrow, MonadResource, MonadTrans
884− , MonadBase b)
882+ , MonadMask, MonadCatch, MonadThrow, MonadTrans, MonadBase b)
885883
886884
887885instance MonadIO m => Katip (KatipT m) where
@@ -903,14 +901,9 @@ instance (MonadBaseControl b m) => MonadBaseControl b (KatipT m) where
903901 restoreM = defaultRestoreM
904902
905903instance MonadUnliftIO m => MonadUnliftIO (KatipT m) where
906−#if MIN_VERSION_unliftio_core(0, 2, 0)
907− withRunInIO inner = KatipT $ ReaderT $ \le -> withRunInIO $ \run ->
908− inner (run . runKatipT le)
909−#else
910904 askUnliftIO = KatipT $
911− withUnliftIO $ \u ->
912− pure (UnliftIO (unliftIO u . unKatipT))
913−#endif
905+ withUnliftIO $ \u ->
906+ pure (UnliftIO (unliftIO u . unKatipT))
914907
915908#if MIN_VERSION_base(4, 9, 0)
916909instance MF.MonadFail m => MF.MonadFail (KatipT m) where
@@ -948,29 +941,19 @@ logItem
948941 -> m ()
949942logItem a ns loc sev msg = do
950943 LogEnv{..} <- getLogEnv
951− logKatipItem =<< liftIO
952− (Item <$> pure _logEnvApp
953− <*> pure _logEnvEnv
954− <*> pure sev
955− <*> (mkThreadIdText <$> myThreadId)
956− <*> pure _logEnvHost
957− <*> pure _logEnvPid
958− <*> pure a
959− <*> pure msg
960− <*> _logEnvTimer
961− <*> pure (_logEnvApp <> ns)
962− <*> pure loc)
963−
964−-- | Log already constructed 'Item'. This is the lowest level function that other log*
965−-- functions use.
966−-- It can be useful when implementing centralised logging services.
967−logKatipItem
968− :: (A.Applicative m, LogItem a, Katip m)
969− => Item a
970− -> m ()
971−logKatipItem item = do
972− LogEnv{..} <- getLogEnv
973− liftIO $
944+ liftIO $ do
945+ item <- Item
946+ <$> pure _logEnvApp
947+ <*> pure _logEnvEnv
948+ <*> pure sev
949+ <*> (mkThreadIdText <$> myThreadId)
950+ <*> pure _logEnvHost
951+ <*> pure _logEnvPid
952+ <*> pure a
953+ <*> pure msg
954+ <*> _logEnvTimer
955+ <*> pure (_logEnvApp <> ns)
956+ <*> pure loc
974957 FT.forM_ (M.elems _logEnvScribes) $ \ ScribeHandle {..} -> do
975958 whenM (scribePermitItem shScribe item) $
976959 void $ atomically (tryWriteTBQueue shChan (NewItem item))
@@ -1019,7 +1002,7 @@ logException
10191002logException a ns sev action = action `catchAny` \e -> f e >> throwM e
10201003 where
10211004 f e = logF a ns sev (msg e)
1022− msg e = ls (T.pack "An exception has occurred: ") <> showLS e
1005+ msg e = ls (T.pack "An exception has occured: ") <> showLS e
10231006
10241007
10251008-------------------------------------------------------------------------------