| Copyright | Copyright (C) 2004-2011 John Goerzen |
|---|---|
| License | BSD3 |
| Maintainer | John Goerzen <jgoerzen@complete.org> |
| Stability | provisional |
| Portability | portable |
| Safe Haskell | None |
| Language | Haskell2010 |
System.Wlog.Logger
Contents
Description
Haskell Logging Framework, Primary Interface
Written by John Goerzen, jgoerzen@complete.org
This module is a modification of System.Log.Logger of hslogger
library. Unless proper description is written here, please use the
original documentation available on hackage/hslogger.
- data Logger
- data Severity
- logM :: String -> Severity -> Text -> IO ()
- logMCond :: String -> Severity -> Text -> (String -> Bool) -> IO ()
- debugM :: String -> Text -> IO ()
- infoM :: String -> Text -> IO ()
- noticeM :: String -> Text -> IO ()
- warningM :: String -> Text -> IO ()
- errorM :: String -> Text -> IO ()
- removeAllHandlers :: IO ()
- traplogging :: String -> Severity -> Text -> IO a -> IO a
- logL :: Logger -> Severity -> Text -> IO ()
- logLCond :: Logger -> Severity -> Text -> (String -> Bool) -> IO ()
- getLogger :: String -> IO Logger
- getRootLogger :: IO Logger
- rootLoggerName :: String
- addHandler :: LogHandler a => a -> Logger -> Logger
- removeHandler :: Logger -> Logger
- setHandlers :: LogHandler a => [a] -> Logger -> Logger
- getLevel :: Logger -> Maybe Severity
- setLevel :: Severity -> Logger -> Logger
- clearLevel :: Logger -> Logger
- saveGlobalLogger :: Logger -> IO ()
- updateGlobalLogger :: String -> (Logger -> Logger) -> IO ()
Basic Types
Re-Exported from System.Wlog
Severity is level of log message importance. It uniquely determines which messages to print.
Logging Messages
Basic
Arguments
| :: String | Name of the logger to use |
| -> Severity | Severity of this message |
| -> Text | The log text itself |
| -> IO () |
Log a message using the given logger at a given priority.
Utility Functions
Log a message at DEBUG priority
Log a message at INFO priority
Log a message at NOTICE priority
Log a message at WARNING priority
Log a message at ERROR priority
removeAllHandlers :: IO () Source #
Allow graceful shutdown. Release all opened fileshandlersetc.
Arguments
| :: String | Logger name |
| -> Severity | Logging priority |
| -> Text | Descriptive text to prepend to logged messages |
| -> IO a | Action to run |
| -> IO a | Return value |
Traps exceptions that may occur, logging them, then passing them on.
Takes a logger name, priority, leading description text (you can set it to
"" if you don't want any), and action to run.
Logging to a particular Logger by object
logL :: Logger -> Severity -> Text -> IO () Source #
Log a message, assuming the current logger's level permits it.
logLCond :: Logger -> Severity -> Text -> (String -> Bool) -> IO () Source #
Logs a message with condition.
Logger Manipulation
Finding ∨ Creating Loggers
getLogger :: String -> IO Logger Source #
Returns the logger for the given name. If no logger with that name exists, creates new loggers and any necessary parent loggers, with no connected handlers.
getRootLogger :: IO Logger Source #
Returns the root logger.
rootLoggerName :: String Source #
The name of the root logger, which is always defined and present on the system.
Modifying Loggers
addHandler :: LogHandler a => a -> Logger -> Logger Source #
removeHandler :: Logger -> Logger Source #
Remove a handler from the Logger. Handlers are removed in the reverse
order they were added, so the following property holds for any LogHandler
h:
removeHandler . addHandler h = id
If no handlers are associated with the Logger, it is returned unchanged.
The root logger's default handler that writes every message to stderr can be removed by using this function before any handlers have been added to the root logger:
updateGlobalLogger rootLoggerName removeHandler
setHandlers :: LogHandler a => [a] -> Logger -> Logger Source #
Set the 'Logger'\'s list of handlers to the list supplied. All existing handlers are removed first.
getLevel :: Logger -> Maybe Severity Source #
Returns the "level" of the logger. Items beneath this level will be ignored.
clearLevel :: Logger -> Logger Source #
Clears the "level" of the Logger. It will now inherit the level of
| its parent.
Saving Your Changes
saveGlobalLogger :: Logger -> IO () Source #
Updates the global record for the given logger to take into account any changes you may have made.
Helps you make changes on the given logger. Takes a function
that makes changes and writes those changes back to the global
database. Here's an example from above ("s" is a LogHandler):
updateGlobalLogger "MyApp.BuggyComponent"
(setLevel DEBUG . setHandlers [s])