module Plutus.Contract.Logging(
  logDebug
  , logInfo
  , logWarn
  , logError
) where


import Data.Aeson (ToJSON (toJSON))
import Plutus.Contract.Types (Contract (..))

import Control.Monad.Freer.Extras.Log qualified as L

-- | Log a message at the 'Debug' level
logDebug :: ToJSON a => a -> Contract w s e ()
logDebug :: a -> Contract w s e ()
logDebug = Eff (ContractEffs w e) () -> Contract w s e ()
forall w (s :: Row *) e a.
Eff (ContractEffs w e) a -> Contract w s e a
Contract (Eff (ContractEffs w e) () -> Contract w s e ())
-> (a -> Eff (ContractEffs w e) ()) -> a -> Contract w s e ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Eff (ContractEffs w e) ()
forall a (effs :: [* -> *]).
Member (LogMsg a) effs =>
a -> Eff effs ()
L.logDebug (Value -> Eff (ContractEffs w e) ())
-> (a -> Value) -> a -> Eff (ContractEffs w e) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Value
forall a. ToJSON a => a -> Value
toJSON

-- | Log a message at the 'Info' level
logInfo :: ToJSON a => a -> Contract w s e ()
logInfo :: a -> Contract w s e ()
logInfo = Eff (ContractEffs w e) () -> Contract w s e ()
forall w (s :: Row *) e a.
Eff (ContractEffs w e) a -> Contract w s e a
Contract (Eff (ContractEffs w e) () -> Contract w s e ())
-> (a -> Eff (ContractEffs w e) ()) -> a -> Contract w s e ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Eff (ContractEffs w e) ()
forall a (effs :: [* -> *]).
Member (LogMsg a) effs =>
a -> Eff effs ()
L.logInfo (Value -> Eff (ContractEffs w e) ())
-> (a -> Value) -> a -> Eff (ContractEffs w e) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Value
forall a. ToJSON a => a -> Value
toJSON

-- | Log a message at the 'Warning' level
logWarn :: ToJSON a => a -> Contract w s e ()
logWarn :: a -> Contract w s e ()
logWarn = Eff (ContractEffs w e) () -> Contract w s e ()
forall w (s :: Row *) e a.
Eff (ContractEffs w e) a -> Contract w s e a
Contract (Eff (ContractEffs w e) () -> Contract w s e ())
-> (a -> Eff (ContractEffs w e) ()) -> a -> Contract w s e ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Eff (ContractEffs w e) ()
forall a (effs :: [* -> *]).
Member (LogMsg a) effs =>
a -> Eff effs ()
L.logWarn (Value -> Eff (ContractEffs w e) ())
-> (a -> Value) -> a -> Eff (ContractEffs w e) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Value
forall a. ToJSON a => a -> Value
toJSON

-- | Log a message at the 'Error' level
logError :: ToJSON a => a -> Contract w s e ()
logError :: a -> Contract w s e ()
logError = Eff (ContractEffs w e) () -> Contract w s e ()
forall w (s :: Row *) e a.
Eff (ContractEffs w e) a -> Contract w s e a
Contract (Eff (ContractEffs w e) () -> Contract w s e ())
-> (a -> Eff (ContractEffs w e) ()) -> a -> Contract w s e ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Eff (ContractEffs w e) ()
forall a (effs :: [* -> *]).
Member (LogMsg a) effs =>
a -> Eff effs ()
L.logError (Value -> Eff (ContractEffs w e) ())
-> (a -> Value) -> a -> Eff (ContractEffs w e) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Value
forall a. ToJSON a => a -> Value
toJSON