From b56dedf7b9f939ad0198425ffcad07f21ec8905e Mon Sep 17 00:00:00 2001 From: Toralf Wittner Date: Sun, 12 Jan 2014 12:23:53 +0100 Subject: [PATCH] Add 'StdErr' as log output. Requires 'fast-logger' >= 2.1.4. --- src/System/Logger.hs | 8 +++++--- tinylog.cabal | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/System/Logger.hs b/src/System/Logger.hs index b86904a..488dbc4 100644 --- a/src/System/Logger.hs +++ b/src/System/Logger.hs @@ -79,6 +79,7 @@ data Settings = Settings data Output = StdOut + | StdErr | Path FilePath deriving (Eq, Ord, Show) @@ -99,13 +100,14 @@ new :: MonadIO m => Settings -> m Logger new s = liftIO $ do n <- fmap (readNote "Invalid LOG_BUFFER") <$> lookupEnv "LOG_BUFFER" l <- fmap (readNote "Invalid LOG_LEVEL") <$> lookupEnv "LOG_LEVEL" - g <- FL.newLoggerSet (fromMaybe FL.defaultBufSize n) (mapOut $ output s) + g <- fn (output s) (fromMaybe FL.defaultBufSize n) c <- clockCache (format s) let s' = s { logLevel = fromMaybe (logLevel s) l } return $ Logger g s' (fst <$> c) (snd <$> c) where - mapOut StdOut = Nothing - mapOut (Path p) = Just p + fn StdOut = FL.newStdoutLoggerSet + fn StdErr = FL.newStderrLoggerSet + fn (Path p) = flip FL.newFileLoggerSet p clockCache "" = return Nothing clockCache f = Just <$> clockDateCacher (DateCacheConf getUnixTime (fmt f)) diff --git a/tinylog.cabal b/tinylog.cabal index 6ae4aa8..53137b8 100644 --- a/tinylog.cabal +++ b/tinylog.cabal @@ -1,5 +1,5 @@ name: tinylog -version: 0.4.1 +version: 0.4.2 synopsis: Simplistic logging using fast-logger. author: Toralf Wittner maintainer: Toralf Wittner @@ -32,7 +32,7 @@ library base == 4.* , bytestring >= 0.10 , date-cache >= 0.3 - , fast-logger >= 2.1.2 && < 2.2 + , fast-logger >= 2.1.4 && < 2.2 , mtl >= 2.1 , transformers >= 0.3 , unix-time >= 0.1 -- GitLab