Safe Haskell | None |
---|---|
Language | Haskell2010 |
Functions for generic, IO-based LogWriter
s.
This module is more low-level than the others in this directory.
Synopsis
- mkLogWriterIO :: HasCallStack => (LogMessage -> IO ()) -> LogWriter IO
- ioHandleLogWriter :: HasCallStack => Handle -> LogWriter IO
- defaultIoLogWriter :: Text -> Facility -> LogWriter IO -> LogWriter IO
- withIoLogging :: SetMember Lift (Lift IO) e => LogWriter IO -> Text -> Facility -> LogPredicate -> Eff (Logs ': (LogWriterReader IO ': e)) a -> Eff e a
- type LoggingAndIo = '[Logs, LogWriterReader IO, Lift IO]
- printLogMessage :: LogMessage -> IO ()
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 LogMessage
s to strings via renderLogMessageConsoleLog
and prints them to an Handle
using hPutStrLn
.
:: Text | The default application name to put into the |
-> Facility | The default RFC-5424 facility to put into the |
-> LogWriter IO | The IO based writer to decorate |
-> LogWriter IO |
Decorate an IO based LogWriter
to fill out these fields in LogMessage
s:
- 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 givenFacility
It works by using mappingLogWriterM
.
:: SetMember Lift (Lift IO) e | |
=> LogWriter IO | The |
-> Text | The default application name to put into the |
-> Facility | The default RFC-5424 facility to put into the |
-> 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 Eff
ects 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.