From 871e711529085c3f6ed8bc2740612fa90489b47f Mon Sep 17 00:00:00 2001 From: Toralf Wittner Date: Tue, 5 Apr 2016 22:47:49 +0200 Subject: [PATCH] Change `setFormat` to accept `Maybe DateFormat`. Commit 5cf41025dbbb7bba7ffc1f7861ae491a747dee6c introduced a bug which prevented client code from being able to clear the date format in settings. By implicitly wrapping the argument in a `Just` the actual timestamp rendering kicked in which produced an empty field in the log output. This commit fixes this behaviour by changing `setFormat` to take a `Maybe DateFormat` parameter. Client code can pass in `Nothing` to disable timestamps. --- CHANGELOG.md | 5 +++++ src/System/Logger/Settings.hs | 6 +++--- tinylog.cabal | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e49f27..b11ef71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +0.14.0 +----------------------------------------------------------------------------- +- `setFormat` now expects a `Maybe DateFormat` to allow for not having a date + format at all. + 0.13.0 ----------------------------------------------------------------------------- - Change `DateFormat` representation to `UnixTime -> ByteString`. This diff --git a/src/System/Logger/Settings.hs b/src/System/Logger/Settings.hs index 236ab0e..9b852f3 100644 --- a/src/System/Logger/Settings.hs +++ b/src/System/Logger/Settings.hs @@ -46,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 :: !(Maybe DateFormat) -- ^ the timestamp format + , _format :: !(Maybe DateFormat) -- ^ the timestamp format (use 'Nothing' to disable timestamps) , _delimiter :: !ByteString -- ^ text to intersperse between fields of a log line , _netstrings :: !Bool -- ^ use encoding (fixes delimiter to \",\") , _bufSize :: !Int -- ^ how many bytes to buffer before commiting to sink @@ -64,8 +64,8 @@ setOutput x s = s { _output = x } format :: Settings -> Maybe DateFormat format = _format -setFormat :: DateFormat -> Settings -> Settings -setFormat x s = s { _format = Just x } +setFormat :: Maybe DateFormat -> Settings -> Settings +setFormat x s = s { _format = x } bufSize :: Settings -> Int bufSize = _bufSize diff --git a/tinylog.cabal b/tinylog.cabal index 3e8ca42..24274ef 100644 --- a/tinylog.cabal +++ b/tinylog.cabal @@ -1,5 +1,5 @@ name: tinylog -version: 0.13.0 +version: 0.14.0 synopsis: Simplistic logging using fast-logger. author: Toralf Wittner maintainer: Toralf Wittner -- GitLab