{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Effectful.Katip (
Namespace (..),
Environment (..),
Severity (..),
renderSeverity,
textToSeverity,
Verbosity (..),
ToObject (..),
LogItem (..),
Item (..),
ThreadIdText (..),
PayloadSelection (..),
Scribe (..),
LogEnv (..),
SimpleLogPayload,
sl,
defaultScribeSettings,
ScribeSettings,
scribeBufferSize,
_scribeBufferSize,
itemApp,
itemEnv,
itemSeverity,
itemThread,
itemHost,
itemProcess,
itemPayload,
itemMessage,
itemTime,
itemNamespace,
itemLoc,
logEnvHost,
logEnvPid,
logEnvApp,
logEnvEnv,
logEnvTimer,
logEnvScribes,
KatipE,
runKatipE,
runKatipContextE,
startKatipE,
startKatipContextE,
registerScribe,
unregisterScribe,
clearScribes,
closeScribe,
LogStr (..),
logStr,
ls,
showLS,
getLogEnv,
localLogEnv,
logF,
logMsg,
logT,
logLoc,
logItem,
logKatipItem,
logException,
getKatipContext,
localKatipContext,
getKatipNamespace,
localKatipNamespace,
logFM,
logTM,
logLocM,
logItemM,
logExceptionM,
AnyLogContext,
LogContexts,
liftPayload,
katipAddNamespace,
katipAddContext,
katipNoLogging,
mkHandleScribe,
mkHandleScribeWithFormatter,
mkFileScribe,
ColorStrategy (..),
ItemFormatter,
bracketFormat,
jsonFormat,
PermitFunc,
permitAND,
permitOR,
permitItem,
payloadObject,
itemJson,
) where
import Effectful
import Effectful.Dispatch.Static
import Katip (
AnyLogContext,
ColorStrategy (..),
Environment (..),
Item (..),
ItemFormatter,
LogContexts,
LogEnv (..),
LogItem (..),
LogStr (..),
Namespace (..),
PayloadSelection (..),
PermitFunc,
Scribe (..),
ScribeSettings,
Severity (..),
SimpleLogPayload,
ThreadIdText (..),
ToObject (..),
Verbosity (..),
bracketFormat,
clearScribes,
defaultScribeSettings,
itemApp,
itemEnv,
itemHost,
itemJson,
itemLoc,
itemMessage,
itemNamespace,
itemPayload,
itemProcess,
itemSeverity,
itemThread,
itemTime,
jsonFormat,
liftPayload,
logEnvApp,
logEnvEnv,
logEnvHost,
logEnvPid,
logEnvScribes,
logEnvTimer,
logStr,
ls,
payloadObject,
permitAND,
permitItem,
permitOR,
renderSeverity,
scribeBufferSize,
showLS,
sl,
textToSeverity,
unregisterScribe,
_scribeBufferSize,
)
import Data.Kind
import Data.Text (Text)
import Katip qualified as K
import Katip.Core (getLocTH)
import Language.Haskell.TH (Loc)
import Language.Haskell.TH.Lib
import System.IO (Handle)
import Unsafe.Coerce (unsafeCoerce)
type KatipE :: Effect
data KatipE m a
type instance DispatchOf KatipE = Static WithSideEffects
data instance StaticRep KatipE = MkKatipE !LogEnv !LogContexts !Namespace
runKatipE :: forall es a. (IOE :> es) => LogEnv -> Eff (KatipE : es) a -> Eff es a
runKatipE :: forall (es :: [Effect]) a.
(IOE :> es) =>
LogEnv -> Eff (KatipE : es) a -> Eff es a
runKatipE LogEnv
l Eff (KatipE : es) a
act = StaticRep KatipE -> Eff (KatipE : es) a -> Eff es a
forall (e :: Effect) (sideEffects :: SideEffects) (es :: [Effect])
a.
(DispatchOf e ~ 'Static sideEffects, MaybeIOE sideEffects es) =>
StaticRep e -> Eff (e : es) a -> Eff es a
evalStaticRep (LogEnv -> LogContexts -> Namespace -> StaticRep KatipE
MkKatipE LogEnv
l LogContexts
forall a. Monoid a => a
mempty Namespace
forall a. Monoid a => a
mempty) Eff (KatipE : es) a
act Eff es a -> Eff es LogEnv -> Eff es a
forall a b. Eff es a -> Eff es b -> Eff es a
forall (f :: Type -> Type) a b. Applicative f => f a -> f b -> f a
<* IO LogEnv -> Eff es LogEnv
forall a. IO a -> Eff es a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (LogEnv -> IO LogEnv
K.closeScribes LogEnv
l)
runKatipContextE :: forall es a a1. (LogItem a, IOE :> es) => LogEnv -> a -> Namespace -> Eff (KatipE : es) a1 -> Eff es a1
runKatipContextE :: forall (es :: [Effect]) a a1.
(LogItem a, IOE :> es) =>
LogEnv -> a -> Namespace -> Eff (KatipE : es) a1 -> Eff es a1
runKatipContextE LogEnv
l a
pl Namespace
ns Eff (KatipE : es) a1
act = StaticRep KatipE -> Eff (KatipE : es) a1 -> Eff es a1
forall (e :: Effect) (sideEffects :: SideEffects) (es :: [Effect])
a.
(DispatchOf e ~ 'Static sideEffects, MaybeIOE sideEffects es) =>
StaticRep e -> Eff (e : es) a -> Eff es a
evalStaticRep (LogEnv -> LogContexts -> Namespace -> StaticRep KatipE
MkKatipE LogEnv
l (a -> LogContexts
forall a. LogItem a => a -> LogContexts
liftPayload a
pl) Namespace
ns) Eff (KatipE : es) a1
act Eff es a1 -> Eff es LogEnv -> Eff es a1
forall a b. Eff es a -> Eff es b -> Eff es a
forall (f :: Type -> Type) a b. Applicative f => f a -> f b -> f a
<* IO LogEnv -> Eff es LogEnv
forall a. IO a -> Eff es a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (LogEnv -> IO LogEnv
K.closeScribes LogEnv
l)
instance forall es. (IOE :> es, KatipE :> es) => K.Katip (Eff es) where
getLogEnv :: (IOE :> es, KatipE :> es) => Eff es LogEnv
getLogEnv :: (IOE :> es, KatipE :> es) => Eff es LogEnv
getLogEnv = Eff es LogEnv
forall (es :: [Effect]). (KatipE :> es) => Eff es LogEnv
getLogEnv
localLogEnv ::
(IOE :> es, KatipE :> es) =>
(LogEnv -> LogEnv) ->
Eff es a ->
Eff es a
localLogEnv :: forall a.
(IOE :> es, KatipE :> es) =>
(LogEnv -> LogEnv) -> Eff es a -> Eff es a
localLogEnv = (LogEnv -> LogEnv) -> Eff es a -> Eff es a
forall (es :: [Effect]) a.
(KatipE :> es) =>
(LogEnv -> LogEnv) -> Eff es a -> Eff es a
localLogEnv
instance forall es. (IOE :> es, KatipE :> es) => K.KatipContext (Eff es) where
getKatipContext :: Eff es LogContexts
getKatipContext :: Eff es LogContexts
getKatipContext = Eff es LogContexts
forall (es :: [Effect]). (KatipE :> es) => Eff es LogContexts
getKatipContext
localKatipContext ::
(IOE :> es, KatipE :> es) =>
(LogContexts -> LogContexts) ->
Eff es a ->
Eff es a
localKatipContext :: forall a.
(IOE :> es, KatipE :> es) =>
(LogContexts -> LogContexts) -> Eff es a -> Eff es a
localKatipContext = (LogContexts -> LogContexts) -> Eff es a -> Eff es a
forall (es :: [Effect]) a.
(KatipE :> es) =>
(LogContexts -> LogContexts) -> Eff es a -> Eff es a
localKatipContext
getKatipNamespace :: (IOE :> es, KatipE :> es) => Eff es Namespace
getKatipNamespace :: (IOE :> es, KatipE :> es) => Eff es Namespace
getKatipNamespace = Eff es Namespace
forall (es :: [Effect]). (KatipE :> es) => Eff es Namespace
getKatipNamespace
localKatipNamespace ::
(IOE :> es, KatipE :> es) =>
(Namespace -> Namespace) ->
Eff es a ->
Eff es a
localKatipNamespace :: forall a.
(IOE :> es, KatipE :> es) =>
(Namespace -> Namespace) -> Eff es a -> Eff es a
localKatipNamespace = (Namespace -> Namespace) -> Eff es a -> Eff es a
forall (es :: [Effect]) a.
(KatipE :> es) =>
(Namespace -> Namespace) -> Eff es a -> Eff es a
localKatipNamespace
startKatipE :: (IOE :> es) => Namespace -> Environment -> Eff (KatipE : es) a -> Eff es a
startKatipE :: forall (es :: [Effect]) a.
(IOE :> es) =>
Namespace -> Environment -> Eff (KatipE : es) a -> Eff es a
startKatipE Namespace
ns Environment
env Eff (KatipE : es) a
act = IO LogEnv -> Eff es LogEnv
forall a. IO a -> Eff es a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Namespace -> Environment -> IO LogEnv
K.initLogEnv Namespace
ns Environment
env) Eff es LogEnv -> (LogEnv -> Eff es a) -> Eff es a
forall a b. Eff es a -> (a -> Eff es b) -> Eff es b
forall (m :: Type -> Type) a b. Monad m => m a -> (a -> m b) -> m b
>>= \LogEnv
lenv -> LogEnv -> Eff (KatipE : es) a -> Eff es a
forall (es :: [Effect]) a.
(IOE :> es) =>
LogEnv -> Eff (KatipE : es) a -> Eff es a
runKatipE LogEnv
lenv Eff (KatipE : es) a
act
startKatipContextE :: (IOE :> es, LogItem a) => Environment -> a -> Namespace -> Eff (KatipE : es) a1 -> Eff es a1
startKatipContextE :: forall (es :: [Effect]) a a1.
(IOE :> es, LogItem a) =>
Environment -> a -> Namespace -> Eff (KatipE : es) a1 -> Eff es a1
startKatipContextE Environment
env a
a Namespace
ns Eff (KatipE : es) a1
act = IO LogEnv -> Eff es LogEnv
forall a. IO a -> Eff es a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Namespace -> Environment -> IO LogEnv
K.initLogEnv Namespace
ns Environment
env) Eff es LogEnv -> (LogEnv -> Eff es a1) -> Eff es a1
forall a b. Eff es a -> (a -> Eff es b) -> Eff es b
forall (m :: Type -> Type) a b. Monad m => m a -> (a -> m b) -> m b
>>= \LogEnv
e -> LogEnv -> a -> Namespace -> Eff (KatipE : es) a1 -> Eff es a1
forall (es :: [Effect]) a a1.
(LogItem a, IOE :> es) =>
LogEnv -> a -> Namespace -> Eff (KatipE : es) a1 -> Eff es a1
runKatipContextE LogEnv
e a
a Namespace
ns Eff (KatipE : es) a1
act
registerScribe :: (KatipE :> es) => Text -> Scribe -> ScribeSettings -> Eff es ()
registerScribe :: forall (es :: [Effect]).
(KatipE :> es) =>
Text -> Scribe -> ScribeSettings -> Eff es ()
registerScribe Text
txt Scribe
scrb ScribeSettings
scrbs = do
MkKatipE LogEnv
lenv LogContexts
lctx Namespace
ns <- Eff es (StaticRep KatipE)
forall (e :: Effect) (sideEffects :: SideEffects) (es :: [Effect]).
(DispatchOf e ~ 'Static sideEffects, e :> es) =>
Eff es (StaticRep e)
getStaticRep
LogEnv
nlenv <- IO LogEnv -> Eff es LogEnv
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO LogEnv -> Eff es LogEnv) -> IO LogEnv -> Eff es LogEnv
forall a b. (a -> b) -> a -> b
$ Text -> Scribe -> ScribeSettings -> LogEnv -> IO LogEnv
K.registerScribe Text
txt Scribe
scrb ScribeSettings
scrbs LogEnv
lenv
StaticRep KatipE -> Eff es ()
forall (e :: Effect) (sideEffects :: SideEffects) (es :: [Effect]).
(DispatchOf e ~ 'Static sideEffects, e :> es) =>
StaticRep e -> Eff es ()
putStaticRep (StaticRep KatipE -> Eff es ()) -> StaticRep KatipE -> Eff es ()
forall a b. (a -> b) -> a -> b
$ LogEnv -> LogContexts -> Namespace -> StaticRep KatipE
MkKatipE LogEnv
nlenv LogContexts
lctx Namespace
ns
closeScribe :: (KatipE :> es) => Text -> Eff es ()
closeScribe :: forall (es :: [Effect]). (KatipE :> es) => Text -> Eff es ()
closeScribe Text
name = do
MkKatipE LogEnv
le LogContexts
lc Namespace
ns <- Eff es (StaticRep KatipE)
forall (e :: Effect) (sideEffects :: SideEffects) (es :: [Effect]).
(DispatchOf e ~ 'Static sideEffects, e :> es) =>
Eff es (StaticRep e)
getStaticRep
LogEnv
newle <- IO LogEnv -> Eff es LogEnv
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO LogEnv -> Eff es LogEnv) -> IO LogEnv -> Eff es LogEnv
forall a b. (a -> b) -> a -> b
$ Text -> LogEnv -> IO LogEnv
K.closeScribe Text
name LogEnv
le
StaticRep KatipE -> Eff es ()
forall (e :: Effect) (sideEffects :: SideEffects) (es :: [Effect]).
(DispatchOf e ~ 'Static sideEffects, e :> es) =>
StaticRep e -> Eff es ()
putStaticRep (StaticRep KatipE -> Eff es ()) -> StaticRep KatipE -> Eff es ()
forall a b. (a -> b) -> a -> b
$ LogEnv -> LogContexts -> Namespace -> StaticRep KatipE
MkKatipE LogEnv
newle LogContexts
lc Namespace
ns
getLogEnv :: forall es. (KatipE :> es) => Eff es LogEnv
getLogEnv :: forall (es :: [Effect]). (KatipE :> es) => Eff es LogEnv
getLogEnv = do
StaticRep KatipE
s <- forall (e :: Effect) (sideEffects :: SideEffects) (es :: [Effect]).
(DispatchOf e ~ 'Static sideEffects, e :> es) =>
Eff es (StaticRep e)
getStaticRep @KatipE
case StaticRep KatipE
s of
MkKatipE LogEnv
le LogContexts
_ Namespace
_ -> LogEnv -> Eff es LogEnv
forall a. a -> Eff es a
forall (m :: Type -> Type) a. Monad m => a -> m a
return LogEnv
le
localLogEnv :: forall es a. (KatipE :> es) => (LogEnv -> LogEnv) -> Eff es a -> Eff es a
localLogEnv :: forall (es :: [Effect]) a.
(KatipE :> es) =>
(LogEnv -> LogEnv) -> Eff es a -> Eff es a
localLogEnv LogEnv -> LogEnv
f = forall (e :: Effect) (sideEffects :: SideEffects) (es :: [Effect])
a.
(DispatchOf e ~ 'Static sideEffects, e :> es) =>
(StaticRep e -> StaticRep e) -> Eff es a -> Eff es a
localStaticRep @KatipE ((StaticRep KatipE -> StaticRep KatipE) -> Eff es a -> Eff es a)
-> (StaticRep KatipE -> StaticRep KatipE) -> Eff es a -> Eff es a
forall a b. (a -> b) -> a -> b
$ \(MkKatipE LogEnv
le LogContexts
lc Namespace
ns) -> LogEnv -> LogContexts -> Namespace -> StaticRep KatipE
MkKatipE (LogEnv -> LogEnv
f LogEnv
le) LogContexts
lc Namespace
ns
getKatipContext :: (KatipE :> es) => Eff es LogContexts
getKatipContext :: forall (es :: [Effect]). (KatipE :> es) => Eff es LogContexts
getKatipContext = do
StaticRep KatipE
s <- forall (e :: Effect) (sideEffects :: SideEffects) (es :: [Effect]).
(DispatchOf e ~ 'Static sideEffects, e :> es) =>
Eff es (StaticRep e)
getStaticRep @KatipE
case StaticRep KatipE
s of
MkKatipE LogEnv
_ LogContexts
lc Namespace
_ -> LogContexts -> Eff es LogContexts
forall a. a -> Eff es a
forall (m :: Type -> Type) a. Monad m => a -> m a
return LogContexts
lc
localKatipContext :: forall es a. (KatipE :> es) => (LogContexts -> LogContexts) -> Eff es a -> Eff es a
localKatipContext :: forall (es :: [Effect]) a.
(KatipE :> es) =>
(LogContexts -> LogContexts) -> Eff es a -> Eff es a
localKatipContext LogContexts -> LogContexts
f = forall (e :: Effect) (sideEffects :: SideEffects) (es :: [Effect])
a.
(DispatchOf e ~ 'Static sideEffects, e :> es) =>
(StaticRep e -> StaticRep e) -> Eff es a -> Eff es a
localStaticRep @KatipE ((StaticRep KatipE -> StaticRep KatipE) -> Eff es a -> Eff es a)
-> (StaticRep KatipE -> StaticRep KatipE) -> Eff es a -> Eff es a
forall a b. (a -> b) -> a -> b
$ \(MkKatipE LogEnv
le LogContexts
lc Namespace
ns) -> LogEnv -> LogContexts -> Namespace -> StaticRep KatipE
MkKatipE LogEnv
le (LogContexts -> LogContexts
f LogContexts
lc) Namespace
ns
getKatipNamespace :: forall es. (KatipE :> es) => Eff es Namespace
getKatipNamespace :: forall (es :: [Effect]). (KatipE :> es) => Eff es Namespace
getKatipNamespace = do
StaticRep KatipE
s <- forall (e :: Effect) (sideEffects :: SideEffects) (es :: [Effect]).
(DispatchOf e ~ 'Static sideEffects, e :> es) =>
Eff es (StaticRep e)
getStaticRep @KatipE
case StaticRep KatipE
s of
MkKatipE LogEnv
_ LogContexts
_ Namespace
ns -> Namespace -> Eff es Namespace
forall a. a -> Eff es a
forall (m :: Type -> Type) a. Monad m => a -> m a
return Namespace
ns
localKatipNamespace :: forall es a. (KatipE :> es) => (Namespace -> Namespace) -> Eff es a -> Eff es a
localKatipNamespace :: forall (es :: [Effect]) a.
(KatipE :> es) =>
(Namespace -> Namespace) -> Eff es a -> Eff es a
localKatipNamespace Namespace -> Namespace
f = forall (e :: Effect) (sideEffects :: SideEffects) (es :: [Effect])
a.
(DispatchOf e ~ 'Static sideEffects, e :> es) =>
(StaticRep e -> StaticRep e) -> Eff es a -> Eff es a
localStaticRep @KatipE ((StaticRep KatipE -> StaticRep KatipE) -> Eff es a -> Eff es a)
-> (StaticRep KatipE -> StaticRep KatipE) -> Eff es a -> Eff es a
forall a b. (a -> b) -> a -> b
$ \(MkKatipE LogEnv
le LogContexts
lc Namespace
ns) -> LogEnv -> LogContexts -> Namespace -> StaticRep KatipE
MkKatipE LogEnv
le LogContexts
lc (Namespace -> StaticRep KatipE) -> Namespace -> StaticRep KatipE
forall a b. (a -> b) -> a -> b
$ Namespace -> Namespace
f Namespace
ns
unsafeEmbedIOE :: forall es a. (KatipE :> es) => ((KatipE :> es, IOE :> es) => Eff es a) -> Eff es a
unsafeEmbedIOE :: forall (es :: [Effect]) a.
(KatipE :> es) =>
((KatipE :> es, IOE :> es) => Eff es a) -> Eff es a
unsafeEmbedIOE (KatipE :> es, IOE :> es) => Eff es a
act = Dict (KatipE :> es, IOE :> es)
-> ((KatipE :> es, IOE :> es) => Eff es a) -> Eff es a
forall (a :: Constraint) r. Dict a -> (a => r) -> r
useDict (Dict (KatipE :> es) -> Dict (KatipE :> es, IOE :> es)
forall a b. a -> b
unsafeCoerce (forall (a :: Constraint). a => Dict a
MkDict @(KatipE :> es)) :: Dict (KatipE :> es, IOE :> es)) Eff es a
(KatipE :> es, IOE :> es) => Eff es a
(KatipE :> es, IOE :> es) => Eff es a
act
type Dict :: Constraint -> Type
data Dict a where
MkDict :: (a) => Dict a
useDict :: forall a r. Dict a -> ((a) => r) -> r
useDict :: forall (a :: Constraint) r. Dict a -> (a => r) -> r
useDict Dict a
MkDict a => r
r = r
a => r
r
logF :: forall a es. (LogItem a, KatipE :> es) => a -> Namespace -> Severity -> LogStr -> Eff es ()
logF :: forall a (es :: [Effect]).
(LogItem a, KatipE :> es) =>
a -> Namespace -> Severity -> LogStr -> Eff es ()
logF a
a Namespace
ns Severity
sev LogStr
logs = ((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ()
forall (es :: [Effect]) a.
(KatipE :> es) =>
((KatipE :> es, IOE :> es) => Eff es a) -> Eff es a
unsafeEmbedIOE (((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ())
-> ((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ()
forall a b. (a -> b) -> a -> b
$ a -> Namespace -> Severity -> LogStr -> Eff es ()
forall (m :: Type -> Type) a.
(Applicative m, LogItem a, Katip m) =>
a -> Namespace -> Severity -> LogStr -> m ()
K.logF a
a Namespace
ns Severity
sev LogStr
logs
logMsg :: forall es. (KatipE :> es) => Namespace -> Severity -> LogStr -> Eff es ()
logMsg :: forall (es :: [Effect]).
(KatipE :> es) =>
Namespace -> Severity -> LogStr -> Eff es ()
logMsg Namespace
ns Severity
sev LogStr
logs = ((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ()
forall (es :: [Effect]) a.
(KatipE :> es) =>
((KatipE :> es, IOE :> es) => Eff es a) -> Eff es a
unsafeEmbedIOE (((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ())
-> ((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ()
forall a b. (a -> b) -> a -> b
$ Namespace -> Severity -> LogStr -> Eff es ()
forall (m :: Type -> Type).
(Applicative m, Katip m) =>
Namespace -> Severity -> LogStr -> m ()
K.logMsg Namespace
ns Severity
sev LogStr
logs
{-# INLINE logT #-}
logT :: ExpQ
logT :: ExpQ
logT = [|\a ns sev msg -> logItem a ns (Just $(ExpQ
getLocTH)) sev msg|]
{-# INLINE logLoc #-}
logLoc :: (LogItem a, KatipE :> es, HasCallStack) => a -> Namespace -> Severity -> LogStr -> Eff es ()
logLoc :: forall a (es :: [Effect]).
(LogItem a, KatipE :> es, HasCallStack) =>
a -> Namespace -> Severity -> LogStr -> Eff es ()
logLoc a
a Namespace
ns Severity
sev LogStr
logs = ((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ()
forall (es :: [Effect]) a.
(KatipE :> es) =>
((KatipE :> es, IOE :> es) => Eff es a) -> Eff es a
unsafeEmbedIOE (((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ())
-> ((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ()
forall a b. (a -> b) -> a -> b
$ a -> Namespace -> Severity -> LogStr -> Eff es ()
forall (m :: Type -> Type) a.
(Applicative m, LogItem a, Katip m, HasCallStack) =>
a -> Namespace -> Severity -> LogStr -> m ()
K.logLoc a
a Namespace
ns Severity
sev LogStr
logs
logItem :: (LogItem a, KatipE :> es) => a -> Namespace -> Maybe Loc -> Severity -> LogStr -> Eff es ()
logItem :: forall a (es :: [Effect]).
(LogItem a, KatipE :> es) =>
a -> Namespace -> Maybe Loc -> Severity -> LogStr -> Eff es ()
logItem a
a Namespace
ns Maybe Loc
loc Severity
sev LogStr
logs = ((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ()
forall (es :: [Effect]) a.
(KatipE :> es) =>
((KatipE :> es, IOE :> es) => Eff es a) -> Eff es a
unsafeEmbedIOE (((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ())
-> ((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ()
forall a b. (a -> b) -> a -> b
$ a -> Namespace -> Maybe Loc -> Severity -> LogStr -> Eff es ()
forall (m :: Type -> Type) a.
(Applicative m, LogItem a, Katip m) =>
a -> Namespace -> Maybe Loc -> Severity -> LogStr -> m ()
K.logItem a
a Namespace
ns Maybe Loc
loc Severity
sev LogStr
logs
logKatipItem :: (LogItem a, KatipE :> es) => Item a -> Eff es ()
logKatipItem :: forall a (es :: [Effect]).
(LogItem a, KatipE :> es) =>
Item a -> Eff es ()
logKatipItem Item a
item = ((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ()
forall (es :: [Effect]) a.
(KatipE :> es) =>
((KatipE :> es, IOE :> es) => Eff es a) -> Eff es a
unsafeEmbedIOE (((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ())
-> ((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ()
forall a b. (a -> b) -> a -> b
$ Item a -> Eff es ()
forall (m :: Type -> Type) a.
(Applicative m, LogItem a, Katip m) =>
Item a -> m ()
K.logKatipItem Item a
item
logException :: (LogItem a, KatipE :> es) => a -> Namespace -> Severity -> Eff es b -> Eff es b
logException :: forall a (es :: [Effect]) b.
(LogItem a, KatipE :> es) =>
a -> Namespace -> Severity -> Eff es b -> Eff es b
logException a
a Namespace
ns Severity
sev Eff es b
act = ((KatipE :> es, IOE :> es) => Eff es b) -> Eff es b
forall (es :: [Effect]) a.
(KatipE :> es) =>
((KatipE :> es, IOE :> es) => Eff es a) -> Eff es a
unsafeEmbedIOE (((KatipE :> es, IOE :> es) => Eff es b) -> Eff es b)
-> ((KatipE :> es, IOE :> es) => Eff es b) -> Eff es b
forall a b. (a -> b) -> a -> b
$ a -> Namespace -> Severity -> Eff es b -> Eff es b
forall (m :: Type -> Type) a b.
(Katip m, LogItem a, MonadCatch m, Applicative m) =>
a -> Namespace -> Severity -> m b -> m b
K.logException a
a Namespace
ns Severity
sev Eff es b
act
logFM :: (KatipE :> es) => Severity -> LogStr -> Eff es ()
logFM :: forall (es :: [Effect]).
(KatipE :> es) =>
Severity -> LogStr -> Eff es ()
logFM Severity
sev LogStr
logs = ((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ()
forall (es :: [Effect]) a.
(KatipE :> es) =>
((KatipE :> es, IOE :> es) => Eff es a) -> Eff es a
unsafeEmbedIOE (((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ())
-> ((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ()
forall a b. (a -> b) -> a -> b
$ Severity -> LogStr -> Eff es ()
forall (m :: Type -> Type).
(Applicative m, KatipContext m) =>
Severity -> LogStr -> m ()
K.logFM Severity
sev LogStr
logs
{-# INLINE logTM #-}
logTM :: ExpQ
logTM :: ExpQ
logTM = [|logItemM (Just $(ExpQ
getLocTH))|]
{-#INLINE logLocM #-}
logLocM :: (KatipE :> es, HasCallStack) => Severity -> LogStr -> Eff es ()
logLocM :: forall (es :: [Effect]).
(KatipE :> es, HasCallStack) =>
Severity -> LogStr -> Eff es ()
logLocM Severity
sev LogStr
logs = ((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ()
forall (es :: [Effect]) a.
(KatipE :> es) =>
((KatipE :> es, IOE :> es) => Eff es a) -> Eff es a
unsafeEmbedIOE (((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ())
-> ((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ()
forall a b. (a -> b) -> a -> b
$ Severity -> LogStr -> Eff es ()
forall (m :: Type -> Type).
(Applicative m, KatipContext m, HasCallStack) =>
Severity -> LogStr -> m ()
K.logLocM Severity
sev LogStr
logs
logItemM :: (KatipE :> es, HasCallStack) => Maybe Loc -> Severity -> LogStr -> Eff es ()
logItemM :: forall (es :: [Effect]).
(KatipE :> es, HasCallStack) =>
Maybe Loc -> Severity -> LogStr -> Eff es ()
logItemM Maybe Loc
loc Severity
sev LogStr
logs = ((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ()
forall (es :: [Effect]) a.
(KatipE :> es) =>
((KatipE :> es, IOE :> es) => Eff es a) -> Eff es a
unsafeEmbedIOE (((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ())
-> ((KatipE :> es, IOE :> es) => Eff es ()) -> Eff es ()
forall a b. (a -> b) -> a -> b
$ Maybe Loc -> Severity -> LogStr -> Eff es ()
forall (m :: Type -> Type).
(Applicative m, KatipContext m, HasCallStack) =>
Maybe Loc -> Severity -> LogStr -> m ()
K.logItemM Maybe Loc
loc Severity
sev LogStr
logs
logExceptionM :: (KatipE :> es) => Eff es a -> Severity -> Eff es a
logExceptionM :: forall (es :: [Effect]) a.
(KatipE :> es) =>
Eff es a -> Severity -> Eff es a
logExceptionM Eff es a
act Severity
sev = ((KatipE :> es, IOE :> es) => Eff es a) -> Eff es a
forall (es :: [Effect]) a.
(KatipE :> es) =>
((KatipE :> es, IOE :> es) => Eff es a) -> Eff es a
unsafeEmbedIOE (((KatipE :> es, IOE :> es) => Eff es a) -> Eff es a)
-> ((KatipE :> es, IOE :> es) => Eff es a) -> Eff es a
forall a b. (a -> b) -> a -> b
$ Eff es a -> Severity -> Eff es a
forall (m :: Type -> Type) a.
(KatipContext m, MonadCatch m, Applicative m) =>
m a -> Severity -> m a
K.logExceptionM Eff es a
act Severity
sev
katipAddNamespace :: (KatipE :> es) => Namespace -> Eff es a -> Eff es a
katipAddNamespace :: forall (es :: [Effect]) a.
(KatipE :> es) =>
Namespace -> Eff es a -> Eff es a
katipAddNamespace Namespace
ns = (Namespace -> Namespace) -> Eff es a -> Eff es a
forall (es :: [Effect]) a.
(KatipE :> es) =>
(Namespace -> Namespace) -> Eff es a -> Eff es a
localKatipNamespace (Namespace -> Namespace -> Namespace
forall a. Semigroup a => a -> a -> a
<> Namespace
ns)
katipAddContext :: (KatipE :> es, LogItem i) => i -> Eff es a -> Eff es a
katipAddContext :: forall (es :: [Effect]) i a.
(KatipE :> es, LogItem i) =>
i -> Eff es a -> Eff es a
katipAddContext i
ctx = (LogContexts -> LogContexts) -> Eff es a -> Eff es a
forall (es :: [Effect]) a.
(KatipE :> es) =>
(LogContexts -> LogContexts) -> Eff es a -> Eff es a
localKatipContext (LogContexts -> LogContexts -> LogContexts
forall a. Semigroup a => a -> a -> a
<> i -> LogContexts
forall a. LogItem a => a -> LogContexts
liftPayload i
ctx)
katipNoLogging :: (KatipE :> es) => Eff es a -> Eff es a
katipNoLogging :: forall (es :: [Effect]) a. (KatipE :> es) => Eff es a -> Eff es a
katipNoLogging = (LogEnv -> LogEnv) -> Eff es a -> Eff es a
forall (es :: [Effect]) a.
(KatipE :> es) =>
(LogEnv -> LogEnv) -> Eff es a -> Eff es a
localLogEnv ((LogEnv -> LogEnv) -> Eff es a -> Eff es a)
-> (LogEnv -> LogEnv) -> Eff es a -> Eff es a
forall a b. (a -> b) -> a -> b
$ \LogEnv
lenv -> LogEnv
lenv{_logEnvScribes = mempty}
mkHandleScribe :: forall es. (KatipE :> es) => ColorStrategy -> Handle -> PermitFunc -> Verbosity -> Eff es Scribe
mkHandleScribe :: forall (es :: [Effect]).
(KatipE :> es) =>
ColorStrategy -> Handle -> PermitFunc -> Verbosity -> Eff es Scribe
mkHandleScribe ColorStrategy
cs Handle
h PermitFunc
pf Verbosity
v = ((KatipE :> es, IOE :> es) => Eff es Scribe) -> Eff es Scribe
forall (es :: [Effect]) a.
(KatipE :> es) =>
((KatipE :> es, IOE :> es) => Eff es a) -> Eff es a
unsafeEmbedIOE (((KatipE :> es, IOE :> es) => Eff es Scribe) -> Eff es Scribe)
-> ((KatipE :> es, IOE :> es) => Eff es Scribe) -> Eff es Scribe
forall a b. (a -> b) -> a -> b
$ IO Scribe -> Eff es Scribe
forall a. IO a -> Eff es a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO Scribe -> Eff es Scribe) -> IO Scribe -> Eff es Scribe
forall a b. (a -> b) -> a -> b
$ ColorStrategy -> Handle -> PermitFunc -> Verbosity -> IO Scribe
K.mkHandleScribe ColorStrategy
cs Handle
h Item a -> IO Bool
PermitFunc
pf Verbosity
v
mkHandleScribeWithFormatter :: forall es. (KatipE :> es) => (forall a. (LogItem a) => ItemFormatter a) -> ColorStrategy -> Handle -> PermitFunc -> Verbosity -> Eff es Scribe
mkHandleScribeWithFormatter :: forall (es :: [Effect]).
(KatipE :> es) =>
(forall a. LogItem a => ItemFormatter a)
-> ColorStrategy
-> Handle
-> PermitFunc
-> Verbosity
-> Eff es Scribe
mkHandleScribeWithFormatter forall a. LogItem a => ItemFormatter a
ifa ColorStrategy
cs Handle
h PermitFunc
pf Verbosity
v = ((KatipE :> es, IOE :> es) => Eff es Scribe) -> Eff es Scribe
forall (es :: [Effect]) a.
(KatipE :> es) =>
((KatipE :> es, IOE :> es) => Eff es a) -> Eff es a
unsafeEmbedIOE (((KatipE :> es, IOE :> es) => Eff es Scribe) -> Eff es Scribe)
-> ((KatipE :> es, IOE :> es) => Eff es Scribe) -> Eff es Scribe
forall a b. (a -> b) -> a -> b
$ IO Scribe -> Eff es Scribe
forall a. IO a -> Eff es a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO Scribe -> Eff es Scribe) -> IO Scribe -> Eff es Scribe
forall a b. (a -> b) -> a -> b
$ (forall a. LogItem a => ItemFormatter a)
-> ColorStrategy -> Handle -> PermitFunc -> Verbosity -> IO Scribe
K.mkHandleScribeWithFormatter ItemFormatter a
forall a. LogItem a => ItemFormatter a
ifa ColorStrategy
cs Handle
h Item a -> IO Bool
PermitFunc
pf Verbosity
v
mkFileScribe :: forall es. (KatipE :> es) => FilePath -> PermitFunc -> Verbosity -> Eff es Scribe
mkFileScribe :: forall (es :: [Effect]).
(KatipE :> es) =>
FilePath -> PermitFunc -> Verbosity -> Eff es Scribe
mkFileScribe FilePath
fp PermitFunc
pf Verbosity
v = ((KatipE :> es, IOE :> es) => Eff es Scribe) -> Eff es Scribe
forall (es :: [Effect]) a.
(KatipE :> es) =>
((KatipE :> es, IOE :> es) => Eff es a) -> Eff es a
unsafeEmbedIOE (((KatipE :> es, IOE :> es) => Eff es Scribe) -> Eff es Scribe)
-> ((KatipE :> es, IOE :> es) => Eff es Scribe) -> Eff es Scribe
forall a b. (a -> b) -> a -> b
$ IO Scribe -> Eff es Scribe
forall a. IO a -> Eff es a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO Scribe -> Eff es Scribe) -> IO Scribe -> Eff es Scribe
forall a b. (a -> b) -> a -> b
$ FilePath -> PermitFunc -> Verbosity -> IO Scribe
K.mkFileScribe FilePath
fp Item a -> IO Bool
PermitFunc
pf Verbosity
v