diff options
author | Paul Oliver <contact@pauloliver.dev> | 2025-01-14 15:42:46 -0800 |
---|---|---|
committer | Paul Oliver <contact@pauloliver.dev> | 2025-01-17 19:16:43 -0800 |
commit | e1fa79eb713c249055fb23fcc6684a94f77d8368 (patch) | |
tree | 5ac5d27b5ffd94ba9591922e7dcfcdb4d0dc198c /hsm-core | |
parent | 00ad7b9a1c798e611a0c0b7fcbfa5ee76c2f39c4 (diff) |
Adds GPIO effect and dummy blinker service
Diffstat (limited to 'hsm-core')
-rw-r--r-- | hsm-core/Hsm/Core/Log.hs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/hsm-core/Hsm/Core/Log.hs b/hsm-core/Hsm/Core/Log.hs index 9bf8b37..6930e90 100644 --- a/hsm-core/Hsm/Core/Log.hs +++ b/hsm-core/Hsm/Core/Log.hs @@ -1,22 +1,27 @@ module Hsm.Core.Log ( withLogIO , logTup + , flushLogger ) 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) +import Effectful.Dispatch.Static (unsafeEff_) +import Effectful.Log qualified as L -- Helper function allows logging within IO, Useful during `resourcet` -- allocation and release operations. -withLogIO :: Log :> es => Eff es (LogLevel -> Text -> IO ()) +withLogIO :: L.Log :> es => Eff es (L.LogLevel -> Text -> IO ()) withLogIO = do - logIO <- getLoggerIO + logIO <- L.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 +logTup :: L.Log :> es => (L.LogLevel, Text) -> Eff es () +logTup (level, message) = L.logMessage level message emptyObject + +flushLogger :: L.Log :> es => Eff es () +flushLogger = L.getLoggerEnv >>= unsafeEff_ . L.waitForLogger . L.leLogger |