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

Loading…
Cancel
Save