@@ -44,8 +44,7 @@ import Control.Monad.Trans.Either
44import Control.Monad.Trans.Except
44import Control.Monad.Trans.Except
45import Control.Monad.Trans.Maybe
45import Control.Monad.Trans.Maybe
46import Control.Monad.Trans.Reader
46import Control.Monad.Trans.Reader
47−import Control.Monad.Trans.Resource (MonadResource, ResourceT,
47+import Control.Monad.Trans.Resource (ResourceT, transResourceT)
49import Control.Monad.Trans.RWS.Lazy (RWST, mapRWST)
48import Control.Monad.Trans.RWS.Lazy (RWST, mapRWST)
50import qualified Control.Monad.Trans.RWS.Strict as Strict (RWST, mapRWST)
49import qualified Control.Monad.Trans.RWS.Strict as Strict (RWST, mapRWST)
51import Control.Monad.Trans.State.Lazy (StateT, mapStateT)
50import Control.Monad.Trans.State.Lazy (StateT, mapStateT)
@@ -665,7 +664,7 @@ makeLenses ''LogEnv
667-------------------------------------------------------------------------------
666-------------------------------------------------------------------------------
668−-- | Create a reasonable default InitLogEnv. Uses an 'AutoUpdate' which
667+-- | Create a reasonable default InitLogEnv. Uses an 'AutoUdate' which
669-- updates the timer every 1ms. If you need even more timestamp
668-- updates the timer every 1ms. If you need even more timestamp
670-- precision at the cost of performance, consider setting
669-- precision at the cost of performance, consider setting
671-- '_logEnvTimer' with 'getCurrentTime'.
670-- '_logEnvTimer' with 'getCurrentTime'.
@@ -880,8 +879,7 @@ instance (Katip m) => Katip (ResourceT m) where
880-- opposed to implementing 'Katip' for your monad.
879-- opposed to implementing 'Katip' for your monad.
881newtype KatipT m a = KatipT { unKatipT :: ReaderT LogEnv m a }
880newtype KatipT m a = KatipT { unKatipT :: ReaderT LogEnv m a }
882 deriving ( Functor, Applicative, Monad, MonadIO
881 deriving ( Functor, Applicative, Monad, MonadIO
883− , MonadMask, MonadCatch, MonadThrow, MonadResource, MonadTrans
882+ , MonadMask, MonadCatch, MonadThrow, MonadTrans, MonadBase b)
887instance MonadIO m => Katip (KatipT m) where
885instance MonadIO m => Katip (KatipT m) where
@@ -903,14 +901,9 @@ instance (MonadBaseControl b m) => MonadBaseControl b (KatipT m) where
903 restoreM = defaultRestoreM
901 restoreM = defaultRestoreM
905instance MonadUnliftIO m => MonadUnliftIO (KatipT m) where
903instance 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)
910 askUnliftIO = KatipT $
904 askUnliftIO = KatipT $
911− withUnliftIO $ \u ->
905+ withUnliftIO $ \u ->
912− pure (UnliftIO (unliftIO u . unKatipT))
906+ pure (UnliftIO (unliftIO u . unKatipT))
915#if MIN_VERSION_base(4, 9, 0)
908#if MIN_VERSION_base(4, 9, 0)
916instance MF.MonadFail m => MF.MonadFail (KatipT m) where
909instance MF.MonadFail m => MF.MonadFail (KatipT m) where
@@ -948,29 +941,19 @@ logItem
949logItem a ns loc sev msg = do
942logItem a ns loc sev msg = do
950 LogEnv{..} <- getLogEnv
943 LogEnv{..} <- getLogEnv
951− logKatipItem =<< liftIO
944+ liftIO $ do
952− (Item <$> pure _logEnvApp
946+ <$> pure _logEnvApp
953− <*> pure _logEnvEnv
947+ <*> pure _logEnvEnv
954− <*> pure sev
948+ <*> pure sev
955− <*> (mkThreadIdText <$> myThreadId)
949+ <*> (mkThreadIdText <$> myThreadId)
956− <*> pure _logEnvHost
950+ <*> pure _logEnvHost
957− <*> pure _logEnvPid
951+ <*> pure _logEnvPid
958− <*> pure a
952+ <*> pure a
959− <*> pure msg
953+ <*> pure msg
960− <*> _logEnvTimer
954+ <*> _logEnvTimer
961− <*> pure (_logEnvApp <> ns)
955+ <*> pure (_logEnvApp <> ns)
962− <*> pure loc)
956+ <*> pure loc
964−-- | Log already constructed 'Item'. This is the lowest level function that other log*
966−-- It can be useful when implementing centralised logging services.
968− :: (A.Applicative m, LogItem a, Katip m)
971−logKatipItem item = do
972− LogEnv{..} <- getLogEnv
974 FT.forM_ (M.elems _logEnvScribes) $ \ ScribeHandle {..} -> do
957 FT.forM_ (M.elems _logEnvScribes) $ \ ScribeHandle {..} -> do
975 whenM (scribePermitItem shScribe item) $
958 whenM (scribePermitItem shScribe item) $
976 void $ atomically (tryWriteTBQueue shChan (NewItem item))
959 void $ atomically (tryWriteTBQueue shChan (NewItem item))
@@ -1019,7 +1002,7 @@ logException
1019logException a ns sev action = action `catchAny` \e -> f e >> throwM e
1002logException a ns sev action = action `catchAny` \e -> f e >> throwM e
1021 f e = logF a ns sev (msg e)
1004 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
1025-------------------------------------------------------------------------------
1008-------------------------------------------------------------------------------