aboutsummaryrefslogtreecommitdiff
path: root/hsm-core/Hsm/Core/Log.hs
blob: 9f1f35752a7bc8d1f9157adaf566bace5d9d3b03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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