This module provides a function that generates hslogger functions automatically using Template Haskell.
- deriveLoggers :: String -> [Priority] -> Q [Dec]
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 given 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:
info :: String -> IO () info s = HSL.infoM "Foo.Bar" ((++) "Foo.Bar: " s) debug :: String -> IO () debug s = HSL.debugM "Foo.Bar" ((++) "Foo.Bar: " s)
The other hslogger priorities follow the same pattern.
So
info "hi there"
would generate the INFO-level log event
Foo.Bar: hi there
Note: System.Log.Logger must be imported qualified, and the qualifier must
match the qualifier given to deriveLoggers
.