module Polysemy.Log.Stdout where
import qualified Data.Text.IO as Text
import Polysemy.Async (Async)
import Polysemy.Conc (Race)
import Polysemy.Resource (Resource)
import Polysemy.Time (GhcTime, interpretTimeGhc)
import Polysemy.Log.Data.DataLog (DataLog)
import Polysemy.Log.Data.Log (Log)
import Polysemy.Log.Data.LogEntry (LogEntry)
import Polysemy.Log.Data.LogMessage (LogMessage)
import Polysemy.Log.Format (formatLogEntry)
import Polysemy.Log.Log (interpretDataLog, interpretLogDataLog, interpretLogDataLogConc)
import Polysemy.Log.Data.Severity (Severity)
import Polysemy.Log.Level (setLogLevel)
interpretDataLogStdoutWith ::
Member (Embed IO) r =>
(a -> Text) ->
InterpreterFor (DataLog a) r
interpretDataLogStdoutWith :: forall (r :: EffectRow) a.
Member (Embed IO) r =>
(a -> Text) -> InterpreterFor (DataLog a) r
interpretDataLogStdoutWith a -> Text
fmt =
(a -> Sem r ()) -> InterpreterFor (DataLog a) r
forall a (r :: EffectRow).
(a -> Sem r ()) -> InterpreterFor (DataLog a) r
interpretDataLog \ a
msg -> IO () -> Sem r ()
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (Handle -> Text -> IO ()
Text.hPutStrLn Handle
stdout (a -> Text
fmt a
msg))
{-# inline interpretDataLogStdoutWith #-}
interpretDataLogStdout ::
Show a =>
Member (Embed IO) r =>
InterpreterFor (DataLog a) r
interpretDataLogStdout :: forall a (r :: EffectRow).
(Show a, Member (Embed IO) r) =>
InterpreterFor (DataLog a) r
interpretDataLogStdout =
(a -> Text) -> InterpreterFor (DataLog a) r
forall (r :: EffectRow) a.
Member (Embed IO) r =>
(a -> Text) -> InterpreterFor (DataLog a) r
interpretDataLogStdoutWith a -> Text
forall b a. (Show a, IsString b) => a -> b
show
{-# inline interpretDataLogStdout #-}
interpretLogStdoutWith ::
Members [Embed IO, GhcTime] r =>
(LogEntry LogMessage -> Text) ->
InterpreterFor Log r
interpretLogStdoutWith :: forall (r :: EffectRow).
Members '[Embed IO, GhcTime] r =>
(LogEntry LogMessage -> Text) -> InterpreterFor Log r
interpretLogStdoutWith LogEntry LogMessage -> Text
fmt =
(LogEntry LogMessage -> Text)
-> InterpreterFor (DataLog (LogEntry LogMessage)) r
forall (r :: EffectRow) a.
Member (Embed IO) r =>
(a -> Text) -> InterpreterFor (DataLog a) r
interpretDataLogStdoutWith LogEntry LogMessage -> Text
fmt (Sem (DataLog (LogEntry LogMessage) : r) a -> Sem r a)
-> (Sem (Log : r) a -> Sem (DataLog (LogEntry LogMessage) : r) a)
-> Sem (Log : r) a
-> Sem r a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Sem (GhcTime : DataLog (LogEntry LogMessage) : r) a
-> Sem (DataLog (LogEntry LogMessage) : r) a
forall (r :: EffectRow).
Member (Embed IO) r =>
InterpreterFor GhcTime r
interpretTimeGhc (Sem (GhcTime : DataLog (LogEntry LogMessage) : r) a
-> Sem (DataLog (LogEntry LogMessage) : r) a)
-> (Sem (Log : r) a
-> Sem (GhcTime : DataLog (LogEntry LogMessage) : r) a)
-> Sem (Log : r) a
-> Sem (DataLog (LogEntry LogMessage) : r) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Sem (Log : GhcTime : DataLog (LogEntry LogMessage) : r) a
-> Sem (GhcTime : DataLog (LogEntry LogMessage) : r) a
forall (r :: EffectRow).
Members '[DataLog (LogEntry LogMessage), GhcTime] r =>
InterpreterFor Log r
interpretLogDataLog (Sem (Log : GhcTime : DataLog (LogEntry LogMessage) : r) a
-> Sem (GhcTime : DataLog (LogEntry LogMessage) : r) a)
-> (Sem (Log : r) a
-> Sem (Log : GhcTime : DataLog (LogEntry LogMessage) : r) a)
-> Sem (Log : r) a
-> Sem (GhcTime : DataLog (LogEntry LogMessage) : r) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Sem (Log : r) a
-> Sem (Log : GhcTime : DataLog (LogEntry LogMessage) : r) a
forall (e2 :: Effect) (e3 :: Effect) (e1 :: Effect)
(r :: EffectRow) a.
Sem (e1 : r) a -> Sem (e1 : e2 : e3 : r) a
raiseUnder2
{-# inline interpretLogStdoutWith #-}
interpretLogStdoutLevelWith ::
Members [Embed IO, GhcTime] r =>
(LogEntry LogMessage -> Text) ->
Maybe Severity ->
InterpreterFor Log r
interpretLogStdoutLevelWith :: forall (r :: EffectRow).
Members '[Embed IO, GhcTime] r =>
(LogEntry LogMessage -> Text)
-> Maybe Severity -> InterpreterFor Log r
interpretLogStdoutLevelWith LogEntry LogMessage -> Text
fmt Maybe Severity
level =
(LogEntry LogMessage -> Text)
-> InterpreterFor (DataLog (LogEntry LogMessage)) r
forall (r :: EffectRow) a.
Member (Embed IO) r =>
(a -> Text) -> InterpreterFor (DataLog a) r
interpretDataLogStdoutWith LogEntry LogMessage -> Text
fmt (Sem (DataLog (LogEntry LogMessage) : r) a -> Sem r a)
-> (Sem (Log : r) a -> Sem (DataLog (LogEntry LogMessage) : r) a)
-> Sem (Log : r) a
-> Sem r a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Maybe Severity
-> Sem (DataLog (LogEntry LogMessage) : r) a
-> Sem (DataLog (LogEntry LogMessage) : r) a
forall (r :: EffectRow) a.
Member (DataLog (LogEntry LogMessage)) r =>
Maybe Severity -> Sem r a -> Sem r a
setLogLevel Maybe Severity
level (Sem (DataLog (LogEntry LogMessage) : r) a
-> Sem (DataLog (LogEntry LogMessage) : r) a)
-> (Sem (Log : r) a -> Sem (DataLog (LogEntry LogMessage) : r) a)
-> Sem (Log : r) a
-> Sem (DataLog (LogEntry LogMessage) : r) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Sem (GhcTime : DataLog (LogEntry LogMessage) : r) a
-> Sem (DataLog (LogEntry LogMessage) : r) a
forall (r :: EffectRow).
Member (Embed IO) r =>
InterpreterFor GhcTime r
interpretTimeGhc (Sem (GhcTime : DataLog (LogEntry LogMessage) : r) a
-> Sem (DataLog (LogEntry LogMessage) : r) a)
-> (Sem (Log : r) a
-> Sem (GhcTime : DataLog (LogEntry LogMessage) : r) a)
-> Sem (Log : r) a
-> Sem (DataLog (LogEntry LogMessage) : r) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Sem (Log : GhcTime : DataLog (LogEntry LogMessage) : r) a
-> Sem (GhcTime : DataLog (LogEntry LogMessage) : r) a
forall (r :: EffectRow).
Members '[DataLog (LogEntry LogMessage), GhcTime] r =>
InterpreterFor Log r
interpretLogDataLog (Sem (Log : GhcTime : DataLog (LogEntry LogMessage) : r) a
-> Sem (GhcTime : DataLog (LogEntry LogMessage) : r) a)
-> (Sem (Log : r) a
-> Sem (Log : GhcTime : DataLog (LogEntry LogMessage) : r) a)
-> Sem (Log : r) a
-> Sem (GhcTime : DataLog (LogEntry LogMessage) : r) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Sem (Log : r) a
-> Sem (Log : GhcTime : DataLog (LogEntry LogMessage) : r) a
forall (e2 :: Effect) (e3 :: Effect) (e1 :: Effect)
(r :: EffectRow) a.
Sem (e1 : r) a -> Sem (e1 : e2 : e3 : r) a
raiseUnder2
{-# inline interpretLogStdoutLevelWith #-}
interpretLogStdout ::
Members [Embed IO, GhcTime] r =>
InterpreterFor Log r
interpretLogStdout :: forall (r :: EffectRow).
Members '[Embed IO, GhcTime] r =>
InterpreterFor Log r
interpretLogStdout =
(LogEntry LogMessage -> Text) -> InterpreterFor Log r
forall (r :: EffectRow).
Members '[Embed IO, GhcTime] r =>
(LogEntry LogMessage -> Text) -> InterpreterFor Log r
interpretLogStdoutWith LogEntry LogMessage -> Text
formatLogEntry
{-# inline interpretLogStdout #-}
interpretLogStdoutLevel ::
Members [Embed IO, GhcTime] r =>
Maybe Severity ->
InterpreterFor Log r
interpretLogStdoutLevel :: forall (r :: EffectRow).
Members '[Embed IO, GhcTime] r =>
Maybe Severity -> InterpreterFor Log r
interpretLogStdoutLevel =
(LogEntry LogMessage -> Text)
-> Maybe Severity -> InterpreterFor Log r
forall (r :: EffectRow).
Members '[Embed IO, GhcTime] r =>
(LogEntry LogMessage -> Text)
-> Maybe Severity -> InterpreterFor Log r
interpretLogStdoutLevelWith LogEntry LogMessage -> Text
formatLogEntry
{-# inline interpretLogStdoutLevel #-}
interpretLogStdout' ::
Member (Embed IO) r =>
InterpreterFor Log r
interpretLogStdout' :: forall (r :: EffectRow).
Member (Embed IO) r =>
InterpreterFor Log r
interpretLogStdout' =
Sem (GhcTime : r) a -> Sem r a
forall (r :: EffectRow).
Member (Embed IO) r =>
InterpreterFor GhcTime r
interpretTimeGhc (Sem (GhcTime : r) a -> Sem r a)
-> (Sem (Log : r) a -> Sem (GhcTime : r) a)
-> Sem (Log : r) a
-> Sem r a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Sem (Log : GhcTime : r) a -> Sem (GhcTime : r) a
forall (r :: EffectRow).
Members '[Embed IO, GhcTime] r =>
InterpreterFor Log r
interpretLogStdout (Sem (Log : GhcTime : r) a -> Sem (GhcTime : r) a)
-> (Sem (Log : r) a -> Sem (Log : GhcTime : r) a)
-> Sem (Log : r) a
-> Sem (GhcTime : r) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Sem (Log : r) a -> Sem (Log : GhcTime : r) a
forall (e2 :: Effect) (e1 :: Effect) (r :: EffectRow) a.
Sem (e1 : r) a -> Sem (e1 : e2 : r) a
raiseUnder
{-# inline interpretLogStdout' #-}
interpretLogStdoutConc ::
Members [Resource, Async, Race, Embed IO] r =>
InterpreterFor Log r
interpretLogStdoutConc :: forall (r :: EffectRow).
Members '[Resource, Async, Race, Embed IO] r =>
InterpreterFor Log r
interpretLogStdoutConc =
Sem (GhcTime : r) a -> Sem r a
forall (r :: EffectRow).
Member (Embed IO) r =>
InterpreterFor GhcTime r
interpretTimeGhc (Sem (GhcTime : r) a -> Sem r a)
-> (Sem (Log : r) a -> Sem (GhcTime : r) a)
-> Sem (Log : r) a
-> Sem r a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
(LogEntry LogMessage -> Text)
-> InterpreterFor (DataLog (LogEntry LogMessage)) (GhcTime : r)
forall (r :: EffectRow) a.
Member (Embed IO) r =>
(a -> Text) -> InterpreterFor (DataLog a) r
interpretDataLogStdoutWith LogEntry LogMessage -> Text
formatLogEntry (Sem (DataLog (LogEntry LogMessage) : GhcTime : r) a
-> Sem (GhcTime : r) a)
-> (Sem (Log : r) a
-> Sem (DataLog (LogEntry LogMessage) : GhcTime : r) a)
-> Sem (Log : r) a
-> Sem (GhcTime : r) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int
-> InterpreterFor Log (DataLog (LogEntry LogMessage) : GhcTime : r)
forall (r :: EffectRow).
Members
'[DataLog (LogEntry LogMessage), Resource, Async, Race, Embed IO]
r =>
Int -> InterpreterFor Log r
interpretLogDataLogConc Int
64 (Sem (Log : DataLog (LogEntry LogMessage) : GhcTime : r) a
-> Sem (DataLog (LogEntry LogMessage) : GhcTime : r) a)
-> (Sem (Log : r) a
-> Sem (Log : DataLog (LogEntry LogMessage) : GhcTime : r) a)
-> Sem (Log : r) a
-> Sem (DataLog (LogEntry LogMessage) : GhcTime : r) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Sem (Log : r) a
-> Sem (Log : DataLog (LogEntry LogMessage) : GhcTime : r) a
forall (e2 :: Effect) (e3 :: Effect) (e1 :: Effect)
(r :: EffectRow) a.
Sem (e1 : r) a -> Sem (e1 : e2 : e3 : r) a
raiseUnder2
{-# inline interpretLogStdoutConc #-}
interpretLogStdoutLevelConc ::
Members [Resource, Async, Race, Embed IO] r =>
Maybe Severity ->
InterpreterFor Log r
interpretLogStdoutLevelConc :: forall (r :: EffectRow).
Members '[Resource, Async, Race, Embed IO] r =>
Maybe Severity -> InterpreterFor Log r
interpretLogStdoutLevelConc Maybe Severity
level =
Sem (GhcTime : r) a -> Sem r a
forall (r :: EffectRow).
Member (Embed IO) r =>
InterpreterFor GhcTime r
interpretTimeGhc (Sem (GhcTime : r) a -> Sem r a)
-> (Sem (Log : r) a -> Sem (GhcTime : r) a)
-> Sem (Log : r) a
-> Sem r a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
(LogEntry LogMessage -> Text)
-> InterpreterFor (DataLog (LogEntry LogMessage)) (GhcTime : r)
forall (r :: EffectRow) a.
Member (Embed IO) r =>
(a -> Text) -> InterpreterFor (DataLog a) r
interpretDataLogStdoutWith LogEntry LogMessage -> Text
formatLogEntry (Sem (DataLog (LogEntry LogMessage) : GhcTime : r) a
-> Sem (GhcTime : r) a)
-> (Sem (Log : r) a
-> Sem (DataLog (LogEntry LogMessage) : GhcTime : r) a)
-> Sem (Log : r) a
-> Sem (GhcTime : r) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Maybe Severity
-> Sem (DataLog (LogEntry LogMessage) : GhcTime : r) a
-> Sem (DataLog (LogEntry LogMessage) : GhcTime : r) a
forall (r :: EffectRow) a.
Member (DataLog (LogEntry LogMessage)) r =>
Maybe Severity -> Sem r a -> Sem r a
setLogLevel Maybe Severity
level (Sem (DataLog (LogEntry LogMessage) : GhcTime : r) a
-> Sem (DataLog (LogEntry LogMessage) : GhcTime : r) a)
-> (Sem (Log : r) a
-> Sem (DataLog (LogEntry LogMessage) : GhcTime : r) a)
-> Sem (Log : r) a
-> Sem (DataLog (LogEntry LogMessage) : GhcTime : r) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int
-> InterpreterFor Log (DataLog (LogEntry LogMessage) : GhcTime : r)
forall (r :: EffectRow).
Members
'[DataLog (LogEntry LogMessage), Resource, Async, Race, Embed IO]
r =>
Int -> InterpreterFor Log r
interpretLogDataLogConc Int
64 (Sem (Log : DataLog (LogEntry LogMessage) : GhcTime : r) a
-> Sem (DataLog (LogEntry LogMessage) : GhcTime : r) a)
-> (Sem (Log : r) a
-> Sem (Log : DataLog (LogEntry LogMessage) : GhcTime : r) a)
-> Sem (Log : r) a
-> Sem (DataLog (LogEntry LogMessage) : GhcTime : r) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Sem (Log : r) a
-> Sem (Log : DataLog (LogEntry LogMessage) : GhcTime : r) a
forall (e2 :: Effect) (e3 :: Effect) (e1 :: Effect)
(r :: EffectRow) a.
Sem (e1 : r) a -> Sem (e1 : e2 : e3 : r) a
raiseUnder2
{-# inline interpretLogStdoutLevelConc #-}