| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Control.Eff.LogWriter.IO
Description
Functions for generic, IO-based LogWriters.
This module is more low-level than the others in this directory.
Synopsis
- mkLogWriterIO :: HasCallStack => (LogMessage -> IO ()) -> LogWriter (Lift IO)
- ioHandleLogWriter :: HasCallStack => Handle -> LogWriter (Lift IO)
- defaultIoLogWriter :: Text -> Facility -> LogWriter (Lift IO) -> LogWriter (Lift IO)
- withIoLogging :: Lifted IO e => LogWriter (Lift IO) -> Text -> Facility -> LogPredicate -> Eff (Logs ': (LogWriterReader (Lift IO) ': e)) a -> Eff e a
- type LoggingAndIo = '[Logs, LogWriterReader (Lift IO), Lift IO]
- printLogMessage :: LogMessage -> IO ()
Documentation
mkLogWriterIO :: HasCallStack => (LogMessage -> IO ()) -> LogWriter (Lift 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 (Lift IO) Source #
A LogWriter that renders LogMessages to strings via renderLogMessageConsoleLog
and prints them to an Handle using hPutStrLn.
Arguments
| :: Text | The default application name to put into the |
| -> Facility | The default RFC-5424 facility to put into the |
| -> LogWriter (Lift IO) | The IO based writer to decorate |
| -> LogWriter (Lift IO) |
Decorate an IO based LogWriter to fill out these fields in LogMessages:
- The messages will carry the given application name in the
lmAppNamefield. - The
lmTimestampfield contains the UTC time of the log event - The
lmHostnamefield contains the FQDN of the current host - The
lmFacilityfield contains the givenFacility
It works by using mappingLogWriterM.
Arguments
| :: Lifted IO e | |
| => LogWriter (Lift 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 (Lift 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 (Lift 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.