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

Safe HaskellNone
LanguageHaskell2010

Control.Eff.LogWriter.File

Description

This helps to setup logging to a file.

Synopsis

Documentation

withFileLogging Source #

Arguments

:: (Lifted IO e, MonadBaseControl IO (Eff e), HasCallStack) 
=> FilePath

Path to the log-file.

-> 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

-> LogMessageTextRenderer

The LogMessage render function

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

Enable logging to a file, with some LogMessage fields preset as described in withRichLogging.

If the file or its directory does not exist, it will be created.

Example:

exampleWithFileLogging :: IO ()
exampleWithFileLogging =
    runLift
  $ withFileLogging "/var/log/my-app.log" "my-app" local7 allLogMessages renderLogMessageConsoleLog
  $ logInfo "Oh, hi there"

To vary the LogWriter use withRichLogging.

withFileLogWriter Source #

Arguments

:: (IoLogging e, MonadBaseControl IO (Eff e), HasCallStack) 
=> FilePath

Path to the log-file.

-> LogMessageTextRenderer 
-> Eff e b 
-> Eff e b 

Enable logging to a file.

If the file or its directory does not exist, it will be created. Example:

exampleWithFileLogWriter :: IO ()
exampleWithFileLogWriter =
    runLift
  $ withoutLogging
  $ withFileLogWriter "test.log" renderLogMessageConsoleLog
  $ logInfo "Oh, hi there"