module Polysemy.Log.Data.Log where
import Polysemy.Internal (send)
import Polysemy.Log.Data.Severity (Severity, Severity(Debug, Trace, Info, Warn, Error, Crit))
import Polysemy.Log.Data.LogMessage (LogMessage(LogMessage))
data Log :: Effect where
Log :: HasCallStack => LogMessage -> Log m ()
log ::
HasCallStack =>
Member Log r =>
Severity ->
Text ->
Sem r ()
log :: Severity -> Text -> Sem r ()
log Severity
severity Text
message =
(HasCallStack => Sem r ()) -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
withFrozenCallStack ((HasCallStack => Sem r ()) -> Sem r ())
-> (HasCallStack => Sem r ()) -> Sem r ()
forall a b. (a -> b) -> a -> b
$
Log (Sem r) () -> Sem r ()
forall (e :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]) a.
Member e r =>
e (Sem r) a -> Sem r a
send (LogMessage -> Log (Sem r) ()
forall (m :: * -> *). HasCallStack => LogMessage -> Log m ()
Log (Severity -> Text -> LogMessage
LogMessage Severity
severity Text
message))
{-# INLINE log #-}
trace ::
HasCallStack =>
Member Log r =>
Text ->
Sem r ()
trace :: Text -> Sem r ()
trace =
(HasCallStack => Text -> Sem r ()) -> Text -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
withFrozenCallStack ((HasCallStack => Text -> Sem r ()) -> Text -> Sem r ())
-> (HasCallStack => Text -> Sem r ()) -> Text -> Sem r ()
forall a b. (a -> b) -> a -> b
$
Severity -> Text -> Sem r ()
forall (r :: [(* -> *) -> * -> *]).
(HasCallStack, Member Log r) =>
Severity -> Text -> Sem r ()
log Severity
Trace
{-# INLINE trace #-}
debug ::
HasCallStack =>
Member Log r =>
Text ->
Sem r ()
debug :: Text -> Sem r ()
debug =
(HasCallStack => Text -> Sem r ()) -> Text -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
withFrozenCallStack ((HasCallStack => Text -> Sem r ()) -> Text -> Sem r ())
-> (HasCallStack => Text -> Sem r ()) -> Text -> Sem r ()
forall a b. (a -> b) -> a -> b
$
Severity -> Text -> Sem r ()
forall (r :: [(* -> *) -> * -> *]).
(HasCallStack, Member Log r) =>
Severity -> Text -> Sem r ()
log Severity
Debug
{-# INLINE debug #-}
info ::
HasCallStack =>
Member Log r =>
Text ->
Sem r ()
info :: Text -> Sem r ()
info =
(HasCallStack => Text -> Sem r ()) -> Text -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
withFrozenCallStack ((HasCallStack => Text -> Sem r ()) -> Text -> Sem r ())
-> (HasCallStack => Text -> Sem r ()) -> Text -> Sem r ()
forall a b. (a -> b) -> a -> b
$
Severity -> Text -> Sem r ()
forall (r :: [(* -> *) -> * -> *]).
(HasCallStack, Member Log r) =>
Severity -> Text -> Sem r ()
log Severity
Info
{-# INLINE info #-}
warn ::
HasCallStack =>
Member Log r =>
Text ->
Sem r ()
warn :: Text -> Sem r ()
warn =
(HasCallStack => Text -> Sem r ()) -> Text -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
withFrozenCallStack ((HasCallStack => Text -> Sem r ()) -> Text -> Sem r ())
-> (HasCallStack => Text -> Sem r ()) -> Text -> Sem r ()
forall a b. (a -> b) -> a -> b
$
Severity -> Text -> Sem r ()
forall (r :: [(* -> *) -> * -> *]).
(HasCallStack, Member Log r) =>
Severity -> Text -> Sem r ()
log Severity
Warn
{-# INLINE warn #-}
error ::
HasCallStack =>
Member Log r =>
Text ->
Sem r ()
error :: Text -> Sem r ()
error =
(HasCallStack => Text -> Sem r ()) -> Text -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
withFrozenCallStack ((HasCallStack => Text -> Sem r ()) -> Text -> Sem r ())
-> (HasCallStack => Text -> Sem r ()) -> Text -> Sem r ()
forall a b. (a -> b) -> a -> b
$
Severity -> Text -> Sem r ()
forall (r :: [(* -> *) -> * -> *]).
(HasCallStack, Member Log r) =>
Severity -> Text -> Sem r ()
log Severity
Error
{-# INLINE error #-}
crit ::
HasCallStack =>
Member Log r =>
Text ->
Sem r ()
crit :: Text -> Sem r ()
crit =
(HasCallStack => Text -> Sem r ()) -> Text -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
withFrozenCallStack ((HasCallStack => Text -> Sem r ()) -> Text -> Sem r ())
-> (HasCallStack => Text -> Sem r ()) -> Text -> Sem r ()
forall a b. (a -> b) -> a -> b
$
Severity -> Text -> Sem r ()
forall (r :: [(* -> *) -> * -> *]).
(HasCallStack, Member Log r) =>
Severity -> Text -> Sem r ()
log Severity
Crit
{-# INLINE crit #-}