module Hydra.TUI.Logging.Handlers where

import Brick (EventM)
import Hydra.Prelude
import Hydra.TUI.Logging.Types (LogMessage (..), Severity (..))
import Lens.Micro.Mtl ((%=))

report :: Severity -> UTCTime -> Text -> EventM n [LogMessage] ()
report :: forall n. Severity -> UTCTime -> Text -> EventM n [LogMessage] ()
report Severity
sev UTCTime
time Text
msg = ([LogMessage] -> Identity [LogMessage])
-> [LogMessage] -> Identity [LogMessage]
forall a. a -> a
id (([LogMessage] -> Identity [LogMessage])
 -> [LogMessage] -> Identity [LogMessage])
-> ([LogMessage] -> [LogMessage]) -> EventM n [LogMessage] ()
forall s (m :: * -> *) a b.
MonadState s m =>
ASetter s s a b -> (a -> b) -> m ()
%= (Severity -> Text -> UTCTime -> LogMessage
LogMessage Severity
sev Text
msg UTCTime
time :)

info :: UTCTime -> Text -> EventM n [LogMessage] ()
info :: forall n. UTCTime -> Text -> EventM n [LogMessage] ()
info = Severity -> UTCTime -> Text -> EventM n [LogMessage] ()
forall n. Severity -> UTCTime -> Text -> EventM n [LogMessage] ()
report Severity
Info

warn :: UTCTime -> Text -> EventM n [LogMessage] ()
warn :: forall n. UTCTime -> Text -> EventM n [LogMessage] ()
warn = Severity -> UTCTime -> Text -> EventM n [LogMessage] ()
forall n. Severity -> UTCTime -> Text -> EventM n [LogMessage] ()
report Severity
Error