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

Safe HaskellNone
LanguageHaskell2010

Control.Eff.LogWriter.IO

Description

Functions for generic, IO-based LogWriters.

This module is more low-level than the others in this directory.

Synopsis

Documentation

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

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

This is just an alias for MkLogWriter but with IO as parameter. This reduces the need to apply something to the extra type argument @IO.

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

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

A LogWriter that renders LogMessages to strings via renderLogMessageConsoleLog and prints them to an Handle using hPutStrLn.

defaultIoLogWriter Source #

Arguments

:: Text

The default application name to put into the lmAppName field.

-> Facility

The default RFC-5424 facility to put into the lmFacility field.

-> LogWriter IO

The IO based writer to decorate

-> LogWriter IO 

Decorate an IO based LogWriter to fill out these fields in LogMessages:

  • The messages will carry the given application name in the lmAppName field.
  • The lmTimestamp field contains the UTC time of the log event
  • The lmHostname field contains the FQDN of the current host
  • The lmFacility field contains the given Facility

It works by using mappingLogWriterM.

withIoLogging Source #

Arguments

:: SetMember Lift (Lift IO) e 
=> LogWriter IO

The LogWriter that will be used to write log messages.

-> Text

The default application name to put into the lmAppName field.

-> Facility

The default RFC-5424 facility to put into the lmFacility field.

-> LogPredicate

The inital predicate for log messages, there are some pre-defined in Control.Eff.Log.Message

-> Eff (Logs ': (LogWriterReader IO ': e)) a 
-> Eff e a 

Enable logging to IO using the defaultIoLogWriter.

Example:

exampleWithIoLogging :: IO ()
exampleWithIoLogging =
    runLift
  $ withIoLogging debugTraceLogWriter
                  "my-app"
                  local7
                  (lmSeverityIsAtLeast informationalSeverity)
  $ logInfo "Oh, hi there"

type LoggingAndIo = '[Logs, LogWriterReader IO, Lift IO] Source #

The concrete list of Effects for logging with an IO based LogWriter, and a LogWriterReader.

printLogMessage :: LogMessage -> IO () Source #

Render a LogMessage but set the timestamp and thread id fields.