module Hsm.Core.Log ( withLogIO , logTup ) where import Data.Aeson.Types (emptyObject) import Data.Text (Text) import Data.Time.Clock (getCurrentTime) import Effectful (Eff, (:>)) import Effectful.Log (Log, LogLevel, getLoggerIO, logMessage) -- Helper function allows logging within IO, Useful during `resourcet` -- allocation and release operations. withLogIO :: Log :> es => Eff es (LogLevel -> Text -> IO ()) withLogIO = do logIO <- getLoggerIO return $ \level message -> do now <- getCurrentTime logIO now level message emptyObject logTup :: Log :> es => (LogLevel, Text) -> Eff es () logTup (level, message) = logMessage level message emptyObject