module Tintin.Capabilities.Logging
( Logging
, Capability
, log
, err
, debug
, stdOut
, mute
)
where
import Tintin.Core
import Tintin.Capabilities
data Logging
data Capability = Capability
{ _log :: Text -> IO ()
, _err :: Text -> IO ()
, _debug :: Text -> IO ()
}
log :: Has Capability e
=> Text
-> Effectful e ()
log = liftCapability _log
err :: Has Capability e
=> Text
-> Effectful e ()
err = liftCapability _err
debug :: Has Capability e
=> Text
-> Effectful e ()
debug = liftCapability _debug
stdOut :: Capability
stdOut = Capability
{ _log = putTextLn
, _err = putTextLn . ("[ERROR] - " <>)
, _debug = putTextLn . ("[DEBUG] - " <>)
}
mute :: Capability
mute = Capability
{ _log = return . const ()
, _debug = return . const ()
, _err = putTextLn . ("[ERROR] - " <>)
}