| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Control.Monad.Log.Extra.File
Contents
- logEmergencyTH :: Q Exp
- logAlertTH :: Q Exp
- logCriticalTH :: Q Exp
- logErrorTH :: Q Exp
- logWarningTH :: Q Exp
- logNoticeTH :: Q Exp
- logInfoTH :: Q Exp
- logInformationalTH :: Q Exp
- logDebugTH :: Q Exp
- logMessageTH :: Q Exp
- data WithFile a = WithFile {
- msgLoc :: Loc
- discardFile :: a
- renderWithFile :: (a -> Doc) -> WithFile a -> Doc
- logSeverityMessageTH :: Severity -> Q Exp
- liftLoc :: Loc -> Q Exp
- data Loc :: * = Loc {}
Getting Started
logging-effect-extra-file supplements logging-effect
with TH splices that capture file information.
Quickstart using file info and severity
testAppFileAndSeverity ::MonadLog(WithSeverity(WithFileDoc)) m => m () testAppFileAndSeverity = do $(logEmergencyTH) "GAH! All systems are down!!!" $(logAlertTH) "Red alert!" $(logCriticalTH) "Critical hit!" $(logErrorTH) "Errors abound!" $(logWarningTH) "Cargo number 2331 has commandeered the vessel" $(logNoticeTH) "Heads up, but it's no biggie." $(logInformationalTH) "Does anyone read these?" $(logDebugTH) "Sleuthing with log messages..."
Quickstart using only file info
testAppFileOnly ::MonadLog(WithFileDoc) m => m () testAppFileOnly = $(logMessageTH) "Heyo!!!"
Convenience logging combinators (TH)
logging-effect-extra-file provides combinators for:
- adding file info to messages (module name and line number)
- adding both file info and severity to messages
In the former case, WithFile will be at the outer-most level of your log
message stack. In the latter case, WithSeverity will be at the outer-most
level of your log message stack, wrapping WithFile.
The package makes no assumptions on what is inside your log messages though.
There is a logXTH combinator for each level in Severity.
With severity
logEmergencyTH :: Q Exp Source #
Generates a function that logs an Emergency message with info from the
source file.
$(logEmergencyTH) "GAH! All systems are down!!!"
logAlertTH :: Q Exp Source #
Generates a function that logs an Alert message with info from the
source file.
$(logAlertTH) "Red alert!"
logCriticalTH :: Q Exp Source #
Generates a function that logs a Critical message with info from the
source file.
$(logCriticalTH) "Critical hit!"
logErrorTH :: Q Exp Source #
Generates a function that logs an Error message with info from the
source file.
$(logErrorTH) "Errors abound!"
logWarningTH :: Q Exp Source #
Generates a function that logs a Warning message with info from the
source file.
$(logWarningTH) "Cargo number 2331 has commandeered the vessel"
logNoticeTH :: Q Exp Source #
Generates a function that logs a Notice message with info from the
source file.
$(logNoticeTH) "Heads up, but it's no biggie."
Generates a function that logs an Informational message with info from the
source file.
$(logInfoTH) "Does anyone read these?"
logInformationalTH :: Q Exp Source #
Deprecated: logInformationalTH is deprecated in favor of logInfoTH.
Generates a function that logs an Informational message with info from the
source file.
$(logInformationalTH) "Does anyone read these?"
logDebugTH :: Q Exp Source #
Generates a function that logs a Debug message with info from the
source file.
$(logDebugTH) "Sleuthing with log messages..."
Without severity
logMessageTH :: Q Exp Source #
Generates a function that logs a message with info from the source file.
$(logMessageTH) "Burn after reading."
Message transformers
File info
Add "File" information to a log message.
Constructors
| WithFile | |
Fields
| |
renderWithFile :: (a -> Doc) -> WithFile a -> Doc Source #
Given a way to render the underlying message a, render a message with its
file info.
>>>let loc = Loc "SomeFile.hs" "some-package" "SomeModule" (1, 1) (1, 1)>>>renderWithFile id (WithFile loc "Some message")[SomeModule:1] Some message
Utilities
logSeverityMessageTH :: Severity -> Q Exp Source #
Generates a function that logs a message with the given Severity and
info from the source file.
Re-exports
Constructors
| Loc | |
Fields
| |