diff options
Diffstat (limited to 'hsm-core/Hsm/Core/Log.hs')
-rw-r--r-- | hsm-core/Hsm/Core/Log.hs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/hsm-core/Hsm/Core/Log.hs b/hsm-core/Hsm/Core/Log.hs new file mode 100644 index 0000000..9f1f357 --- /dev/null +++ b/hsm-core/Hsm/Core/Log.hs @@ -0,0 +1,20 @@ +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) + +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 |