Browse Source

logging: tweak time format and severity logging

master
Denis Tereshkin 4 years ago
parent
commit
4edd0ea664
  1. 8
      src/ATrade/Logging.hs

8
src/ATrade/Logging.hs

@ -28,7 +28,7 @@ import Colog (LogAction (unLogAction), WithLog, @@ -28,7 +28,7 @@ import Colog (LogAction (unLogAction), WithLog,
import Control.Monad.IO.Class (MonadIO (liftIO))
import qualified Data.Text as T
import Data.Time (UTCTime, defaultTimeLocale,
getCurrentTime)
formatTime, getCurrentTime)
import Data.Time.Format.ISO8601 (iso8601Show)
import Prelude hiding (log)
import System.Console.ANSI (Color (Cyan, Green, Red, White, Yellow),
@ -56,9 +56,9 @@ data Message = @@ -56,9 +56,9 @@ data Message =
fmtMessage :: Message -> T.Text
fmtMessage Message{..} =
(bracketed . T.pack . iso8601Show) msgTimestamp <>
bracketed msgComponent <>
(bracketed . T.pack . formatTime defaultTimeLocale "%Y-%m-%d %H:%M:%S") msgTimestamp <>
showSeverity msgSeverity <>
bracketed msgComponent <>
" " <>
msgText
where
@ -67,7 +67,7 @@ fmtMessage Message{..} = @@ -67,7 +67,7 @@ fmtMessage Message{..} =
showSeverity :: Severity -> T.Text
showSeverity = \case
Trace -> color White Dull "[Trace ]"
Debug -> color Cyan Dull "[Debug] "
Debug -> color Green Dull "[Debug ]"
Info -> color Green Vivid "[Info ]"
Warning -> color Yellow Vivid "[Warning]"
Error -> color Red Vivid "[Error ]"

Loading…
Cancel
Save