From cc639b06c7126fac7b445d8f778455620d7f8f50 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Sun, 29 Dec 2024 17:05:34 +0000 Subject: Initial --- hsm-core/Hsm/Core/Log.hs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 hsm-core/Hsm/Core/Log.hs (limited to 'hsm-core/Hsm/Core/Log.hs') 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 -- cgit v1.2.1