Skip to content

Commit

Permalink
Pad timestamps in --verbose output
Browse files Browse the repository at this point in the history
  • Loading branch information
sjakobi committed Oct 25, 2015
1 parent 4617847 commit 7fcae1b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Stack/Types/StackT.hs
Expand Up @@ -302,9 +302,18 @@ loggerFunc loc _src level msg =
where getDate
| maxLogLevel <= LevelDebug =
do now <- getCurrentTime
return (formatTime defaultTimeLocale "%Y-%m-%d %T%Q" now ++
": ")
return (formatTime' now ++ ": ")
| otherwise = return ""
where
formatTime' = padTimeStamp . formatTime defaultTimeLocale "%Y-%m-%d %T%Q"
-- The padding is necessary because %Q doesn't create trailing zeros.
padTimeStamp ts
-- For a whole number of seconds, %Q produces the empty string.
| timeStampLength - length ts == 7 =
ts ++ ".000000"
| otherwise =
take timeStampLength (ts ++ "000000")
timeStampLength = length ("2015-10-25 14:10:52.641125" :: String)
getLevel
| maxLogLevel <= LevelDebug =
return ("[" ++
Expand Down

0 comments on commit 7fcae1b

Please sign in to comment.