This module provides functions that generate hslogger functions using Template Haskell.
Notes:
- System.Log.Logger must be imported qualified, and the qualifier must
match the qualifier given to
deriveLoggers
and/orderiveNamedLoggers
. - Don't forget to enable Template Haskell preprocessing: specify the pragma
LANGUAGE TemplateHaskell
at the top of your source file orextensions: TemplateHaskell
in your cabal file.
Documentation
:: String | Must match qualifier on import of System.Log.Logger. |
-> [Priority] | List of priorities for which to generate logging functions. |
-> Q [Dec] |
Generate hslogger functions for a list of priorities.
Example usage:
module Foo.Bar ( ... ) where import System.Log.Logger.TH (deriveLoggers) import qualified System.Log.Logger as HSL $(deriveLoggers "HSL" [HSL.DEBUG, HSL.INFO])
Used this way, deriveLoggers
would generate the following functions:
infoM :: MonadIO m => String -> m () infoM s = liftIO (HSL.infoM "Foo.Bar" ((++) "Foo.Bar: " s)) debugM :: MonadIO m => String -> m () debugM s = liftIO (HSL.debugM "Foo.Bar" ((++) "Foo.Bar: " s))
The other hslogger priorities follow the same pattern.
So
infoM "hi there"
would generate the INFO-level log event
Foo.Bar: hi there
:: String | Message prefix, e.g., SomeProgram. |
-> String | Must match qualifier on import of System.Log.Logger. |
-> [Priority] | List of priorities for which to generate logging functions. |
-> Q [Dec] |
Like deriveLoggers
, but allows you to specify a message prefix. This
could be useful if the automatically determined module name (e.g., "Main")
would not be informative enough.