extensible-effects-concurrent-0.19.0: Message passing concurrency as extensible-effect

Safe HaskellNone
LanguageHaskell2010

Control.Eff.Log.Writer

Contents

Description

The LogWriter type encapsulates an effectful function to write LogMessages.

Used in conjunction with the SupportsLogger class, it can be used to write messages from within an effectful computation.

Synopsis

LogWriter Definition

newtype LogWriter writerM Source #

A function that takes a log message and returns an effect that logs the message.

Constructors

MkLogWriter 

Fields

Instances
Applicative w => Default (LogWriter w) Source # 
Instance details

Defined in Control.Eff.Log.Writer

Methods

def :: LogWriter w #

Handle (LogWriterReader h) e a (LogWriter h -> k) Source # 
Instance details

Defined in Control.Eff.Log.Handler

Methods

handle :: (Eff e a -> LogWriter h -> k) -> Arrs e v a -> LogWriterReader h v -> LogWriter h -> k #

handle_relay :: (e ~ (LogWriterReader h ': r'), Relay (LogWriter h -> k) r') => (a -> LogWriter h -> k) -> (Eff e a -> LogWriter h -> k) -> Eff e a -> LogWriter h -> k #

respond_relay :: (a -> LogWriter h -> k) -> (Eff e a -> LogWriter h -> k) -> Eff e a -> LogWriter h -> k #

class SupportsLogger h e where Source #

This class describes how to lift the log writer action into some monad.

The second parameter is almost always Eff x so usually the method of this class lifts the log writer action into an effect monad.

Methods

liftLogWriter :: LogWriter h -> LogMessage -> Eff e () Source #

Instances
Lifted IO e => SupportsLogger IO e Source # 
Instance details

Defined in Control.Eff.Log.Writer

Member CapturedLogsWriter e => SupportsLogger CaptureLogs e Source #

A LogWriter monad for pure logging.

The SupportsLogger instance for this type assumes a Writer effect.

Instance details

Defined in Control.Eff.Log.Writer

SupportsLogger PureLogWriter e Source #

A LogWriter monad for Trace based pure logging.

Instance details

Defined in Control.Eff.Log.Writer

LogWriter Zoo

Pure Writer

noOpLogWriter :: Applicative m => LogWriter m Source #

This LogWriter will discard all messages.

NOTE: This is just an alias for def

debugTraceLogWriter :: Monad h => LogWriter h Source #

A LogWriter that applies renderLogMessage to the log message and then traces it using traceM. This LogWriter work with any base monad.

newtype PureLogWriter a Source #

A base monad for all side effect free LogWriter.

This is only required e.g. when logs are only either discarded or traced. See debugTraceLogWriter or noOpLogWriter.

This is just a wrapper around Identity and serves as a type that has a special SupportsLogger instance.

Constructors

MkPureLogWriter 
Instances
Monad PureLogWriter Source # 
Instance details

Defined in Control.Eff.Log.Writer

Functor PureLogWriter Source # 
Instance details

Defined in Control.Eff.Log.Writer

Methods

fmap :: (a -> b) -> PureLogWriter a -> PureLogWriter b #

(<$) :: a -> PureLogWriter b -> PureLogWriter a #

Applicative PureLogWriter Source # 
Instance details

Defined in Control.Eff.Log.Writer

SupportsLogger PureLogWriter e Source #

A LogWriter monad for Trace based pure logging.

Instance details

Defined in Control.Eff.Log.Writer

listLogWriter :: LogWriter CaptureLogs Source #

A LogWriter monad that provides pure logging by capturing via the Writer effect.

newtype CaptureLogs a Source #

A LogWriter monad that provides pure logging by capturing via the Writer effect.

Constructors

MkCaptureLogs 
Instances
Monad CaptureLogs Source # 
Instance details

Defined in Control.Eff.Log.Writer

Functor CaptureLogs Source # 
Instance details

Defined in Control.Eff.Log.Writer

Methods

fmap :: (a -> b) -> CaptureLogs a -> CaptureLogs b #

(<$) :: a -> CaptureLogs b -> CaptureLogs a #

Applicative CaptureLogs Source # 
Instance details

Defined in Control.Eff.Log.Writer

Methods

pure :: a -> CaptureLogs a #

(<*>) :: CaptureLogs (a -> b) -> CaptureLogs a -> CaptureLogs b #

liftA2 :: (a -> b -> c) -> CaptureLogs a -> CaptureLogs b -> CaptureLogs c #

(*>) :: CaptureLogs a -> CaptureLogs b -> CaptureLogs b #

(<*) :: CaptureLogs a -> CaptureLogs b -> CaptureLogs a #

Member CapturedLogsWriter e => SupportsLogger CaptureLogs e Source #

A LogWriter monad for pure logging.

The SupportsLogger instance for this type assumes a Writer effect.

Instance details

Defined in Control.Eff.Log.Writer

type CapturedLogsWriter = Writer LogMessage Source #

Alias for the Writer that contains the captured LogMessages from CaptureLogs.

runCapturedLogsWriter :: Eff (CapturedLogsWriter ': e) a -> Eff e (a, [LogMessage]) Source #

Run a Writer for LogMessages.

Such a Writer is needed for CaptureLogs

IO Based LogWriter

consoleLogWriter :: LogWriter IO Source #

Write LogMessages to standard output, formatted with printLogMessage.

ioHandleLogWriter :: HasCallStack => Handle -> LogWriter IO Source #

A LogWriter that uses an IO action to write the message.

General Combinator

filteringLogWriter :: Monad e => LogPredicate -> LogWriter e -> LogWriter e Source #

A LogWriter that applies a predicate to the LogMessage and delegates to to the given writer of the predicate is satisfied.

mappingLogWriter :: (LogMessage -> LogMessage) -> LogWriter e -> LogWriter e Source #

A LogWriter that applies a function to the LogMessage and delegates the result to to the given writer.

mappingLogWriterM :: Monad e => (LogMessage -> e LogMessage) -> LogWriter e -> LogWriter e Source #

Like mappingLogWriter allow the function that changes the LogMessage to have effects.

IO Based Combinator

ioLogWriter :: HasCallStack => (LogMessage -> IO ()) -> LogWriter IO Source #

A LogWriter that uses an IO action to write the message.

Example use cases for this function are the consoleLogWriter and the ioHandleLogWriter.

defaultIoLogWriter :: String -> Facility -> LogWriter IO -> LogWriter IO Source #

Decorate an IO based LogWriter to set important fields in log messages.

ALl log messages are censored to include basic log message information:

It installs the given LogWriter, wrapped using mappingLogWriterM.