Commit 871e7115 authored by Toralf Wittner's avatar Toralf Wittner
Browse files

Change `setFormat` to accept `Maybe DateFormat`.

Commit 5cf41025 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.
parent bf470176
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
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
+3 −3
Original line number Diff line number Diff line
@@ -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 <http://cr.yp.to/proto/netstrings.txt netstrings> 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
+1 −1
Original line number Diff line number Diff line
name:                 tinylog
version:              0.13.0
version:              0.14.0
synopsis:             Simplistic logging using fast-logger.
author:               Toralf Wittner
maintainer:           Toralf Wittner <tw@dtex.org>