blob: 9bf8b37bfa7e38012266e5f0f237d85fda1933be (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
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
|