diff options
author | Ben Sima <ben@bsima.me> | 2020-03-29 05:00:59 -0700 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2020-03-29 07:49:02 -0700 |
commit | 22bbc12e63c5fb4fd57ebd0f7a720dcda050d9ca (patch) | |
tree | 0da03d7914f5a3724b9c58209835ad414b2e1497 /Com/MusicMeetsComics/Server/Logger.hs | |
parent | 831620c6ae0461228e0801de92dfc6671333a079 (diff) |
Bump nixpkgs pin
Diffstat (limited to 'Com/MusicMeetsComics/Server/Logger.hs')
-rw-r--r-- | Com/MusicMeetsComics/Server/Logger.hs | 67 |
1 files changed, 35 insertions, 32 deletions
diff --git a/Com/MusicMeetsComics/Server/Logger.hs b/Com/MusicMeetsComics/Server/Logger.hs index eb37ef6..5091b23 100644 --- a/Com/MusicMeetsComics/Server/Logger.hs +++ b/Com/MusicMeetsComics/Server/Logger.hs @@ -3,46 +3,49 @@ module Com.MusicMeetsComics.Server.Logger ( adapt , defaultLogEnv - , logMsg - , runKatipT - , KatipT(..) - , Katip(..) - , LogEnv - , Severity(..) - ) where + , Katip.logMsg + , Katip.runKatipT + , Katip.KatipT(..) + , Katip.Katip(..) + , Katip.LogEnv + , Katip.Severity(..) + ) +where -import Control.Monad.Logger -import qualified Control.Monad.Logger as Logger -import Katip +import qualified Control.Monad.Logger as Logger +import qualified Katip import Protolude -import qualified System.IO as IO -import qualified System.Log.FastLogger as FastLogger +import qualified System.IO as IO +import qualified System.Log.FastLogger as FastLogger -defaultLogEnv :: IO LogEnv +defaultLogEnv :: IO Katip.LogEnv defaultLogEnv = do - handleScribe <- mkHandleScribe ColorIfTerminal IO.stdout DebugS V2 - env <- initLogEnv "hero" "production" - registerScribe "stdout" handleScribe defaultScribeSettings env + handleScribe <- Katip.mkHandleScribe Katip.ColorIfTerminal + IO.stdout + (Katip.permitItem Katip.DebugS) + Katip.V2 + env <- Katip.initLogEnv "hero" "production" + Katip.registerScribe "stdout" handleScribe Katip.defaultScribeSettings env -fromLevel :: LogLevel -> Severity -fromLevel LevelDebug = DebugS -fromLevel LevelInfo = InfoS -fromLevel LevelWarn = WarningS -fromLevel LevelError = ErrorS -fromLevel (LevelOther _) = NoticeS +fromLevel :: Logger.LogLevel -> Katip.Severity +fromLevel Logger.LevelDebug = Katip.DebugS +fromLevel Logger.LevelInfo = Katip.InfoS +fromLevel Logger.LevelWarn = Katip.WarningS +fromLevel Logger.LevelError = Katip.ErrorS +fromLevel (Logger.LevelOther _) = Katip.NoticeS -- | Transforms Katip logMsg into monadLoggerLog to be used inside -- MonadLogger monad -adapt :: - (ToLogStr msg, Applicative m, Katip m) - => (Namespace -> Severity -> Katip.LogStr -> m ()) - -> Loc - -> LogSource - -> LogLevel +adapt + :: (FastLogger.ToLogStr msg, Applicative m, Katip.Katip m) + => (Katip.Namespace -> Katip.Severity -> Katip.LogStr -> m ()) + -> Logger.Loc + -> Logger.LogSource + -> Logger.LogLevel -> msg -> m () adapt f _ src lvl msg = f ns (fromLevel lvl) $ logStr' msg - where - ns = Namespace [src] - -- not sure how fast this is going to be - logStr' = Katip.logStr . FastLogger.fromLogStr . Logger.toLogStr + where + ns = Katip.Namespace [src] + -- not sure how fast this is going to be + logStr' = Katip.logStr . FastLogger.fromLogStr . Logger.toLogStr |