Loading src/System/Logger.hs +3 −5 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ module System.Logger , Logger , Level (..) , Output (..) , DateFormat , DateFormat (..) , iso8601UTC -- * Core API Loading @@ -57,7 +57,6 @@ module System.Logger ) where import Control.Applicative import Control.AutoUpdate import Control.Monad import Control.Monad.IO.Class import Data.Maybe (fromMaybe) Loading Loading @@ -120,9 +119,8 @@ new s = liftIO $ do fn StdErr = FL.newStderrLoggerSet fn (Path p) = flip FL.newFileLoggerSet p mkGetDate "" = return (return id) mkGetDate f = mkAutoUpdate defaultUpdateSettings { updateAction = msg . formatUnixTimeGMT (template f) <$> getUnixTime } mkGetDate Nothing = return (return id) mkGetDate (Just f) = return (msg . (display f) <$> getUnixTime) mergeWith m e = Map.fromList (readNote "Invalid LOG_LEVEL_MAP" e) `Map.union` m Loading src/System/Logger/Settings.hs +24 −15 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import Data.ByteString (ByteString) import Data.ByteString.Char8 (pack) import Data.Map.Strict as Map import Data.Text (Text) import Data.UnixTime import System.Log.FastLogger (defaultBufSize) import System.Logger.Message Loading @@ -45,7 +46,7 @@ data Settings = Settings { _logLevel :: !Level -- ^ messages below this log level will be suppressed , _levelMap :: !(Map Text Level) -- ^ log level per named logger , _output :: !Output -- ^ log sink , _format :: !DateFormat -- ^ the timestamp format (use \"\" to disable timestamps) , _format :: !(Maybe DateFormat) -- ^ the timestamp format , _delimiter :: !ByteString -- ^ text to intersperse between fields of a log line , _netstrings :: !Bool -- ^ use <http://cr.yp.to/proto/netstrings.txt netstrings> encoding (fixes delimiter to \",\") , _bufSize :: !Int -- ^ how many bytes to buffer before commiting to sink Loading @@ -60,11 +61,11 @@ setOutput :: Output -> Settings -> Settings setOutput x s = s { _output = x } -- | The time and date format used for the timestamp part of a log line. format :: Settings -> DateFormat format :: Settings -> Maybe DateFormat format = _format setFormat :: DateFormat -> Settings -> Settings setFormat x s = s { _format = x } setFormat x s = s { _format = Just x } bufSize :: Settings -> Int bufSize = _bufSize Loading Loading @@ -135,11 +136,11 @@ data Output deriving (Eq, Ord, Show) newtype DateFormat = DateFormat { template :: ByteString } deriving (Eq, Ord, Show) { display :: UnixTime -> ByteString } instance IsString DateFormat where fromString = DateFormat . pack fromString = DateFormat . formatUnixTimeGMT . pack -- | ISO 8601 date-time format. iso8601UTC :: DateFormat Loading @@ -162,5 +163,13 @@ iso8601UTC = "%Y-%0m-%0dT%0H:%0M:%0SZ" -- * 'name' = Nothing -- defSettings :: Settings defSettings = Settings Debug Map.empty StdOut iso8601UTC ", " False defaultBufSize Nothing id defSettings = Settings Debug Map.empty StdOut (Just iso8601UTC) ", " False defaultBufSize Nothing id tinylog.cabal +0 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,6 @@ library build-depends: base >= 4.6 && < 5 , bytestring >= 0.10.4 && < 1.0 , auto-update >= 0.1 && < 0.2 , containers >= 0.5 , double-conversion >= 0.2 && < 3.0 , fast-logger >= 2.1.4 && < 3.0 Loading Loading
src/System/Logger.hs +3 −5 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ module System.Logger , Logger , Level (..) , Output (..) , DateFormat , DateFormat (..) , iso8601UTC -- * Core API Loading @@ -57,7 +57,6 @@ module System.Logger ) where import Control.Applicative import Control.AutoUpdate import Control.Monad import Control.Monad.IO.Class import Data.Maybe (fromMaybe) Loading Loading @@ -120,9 +119,8 @@ new s = liftIO $ do fn StdErr = FL.newStderrLoggerSet fn (Path p) = flip FL.newFileLoggerSet p mkGetDate "" = return (return id) mkGetDate f = mkAutoUpdate defaultUpdateSettings { updateAction = msg . formatUnixTimeGMT (template f) <$> getUnixTime } mkGetDate Nothing = return (return id) mkGetDate (Just f) = return (msg . (display f) <$> getUnixTime) mergeWith m e = Map.fromList (readNote "Invalid LOG_LEVEL_MAP" e) `Map.union` m Loading
src/System/Logger/Settings.hs +24 −15 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import Data.ByteString (ByteString) import Data.ByteString.Char8 (pack) import Data.Map.Strict as Map import Data.Text (Text) import Data.UnixTime import System.Log.FastLogger (defaultBufSize) import System.Logger.Message Loading @@ -45,7 +46,7 @@ data Settings = Settings { _logLevel :: !Level -- ^ messages below this log level will be suppressed , _levelMap :: !(Map Text Level) -- ^ log level per named logger , _output :: !Output -- ^ log sink , _format :: !DateFormat -- ^ the timestamp format (use \"\" to disable timestamps) , _format :: !(Maybe DateFormat) -- ^ the timestamp format , _delimiter :: !ByteString -- ^ text to intersperse between fields of a log line , _netstrings :: !Bool -- ^ use <http://cr.yp.to/proto/netstrings.txt netstrings> encoding (fixes delimiter to \",\") , _bufSize :: !Int -- ^ how many bytes to buffer before commiting to sink Loading @@ -60,11 +61,11 @@ setOutput :: Output -> Settings -> Settings setOutput x s = s { _output = x } -- | The time and date format used for the timestamp part of a log line. format :: Settings -> DateFormat format :: Settings -> Maybe DateFormat format = _format setFormat :: DateFormat -> Settings -> Settings setFormat x s = s { _format = x } setFormat x s = s { _format = Just x } bufSize :: Settings -> Int bufSize = _bufSize Loading Loading @@ -135,11 +136,11 @@ data Output deriving (Eq, Ord, Show) newtype DateFormat = DateFormat { template :: ByteString } deriving (Eq, Ord, Show) { display :: UnixTime -> ByteString } instance IsString DateFormat where fromString = DateFormat . pack fromString = DateFormat . formatUnixTimeGMT . pack -- | ISO 8601 date-time format. iso8601UTC :: DateFormat Loading @@ -162,5 +163,13 @@ iso8601UTC = "%Y-%0m-%0dT%0H:%0M:%0SZ" -- * 'name' = Nothing -- defSettings :: Settings defSettings = Settings Debug Map.empty StdOut iso8601UTC ", " False defaultBufSize Nothing id defSettings = Settings Debug Map.empty StdOut (Just iso8601UTC) ", " False defaultBufSize Nothing id
tinylog.cabal +0 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,6 @@ library build-depends: base >= 4.6 && < 5 , bytestring >= 0.10.4 && < 1.0 , auto-update >= 0.1 && < 0.2 , containers >= 0.5 , double-conversion >= 0.2 && < 3.0 , fast-logger >= 2.1.4 && < 3.0 Loading