log-warper-1.3.2: Flexible, configurable, monadic and pretty logging

CopyrightCopyright (C) 2004-2011 John Goerzen
LicenseBSD3
MaintainerJohn Goerzen <jgoerzen@complete.org>
Stabilityprovisional
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

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.

Synopsis

Basic Types

data Logger Source #

Instances

Generic Logger Source # 

Associated Types

type Rep Logger :: * -> * #

Methods

from :: Logger -> Rep Logger x #

to :: Rep Logger x -> Logger #

type Rep Logger Source # 
type Rep Logger

Re-Exported from System.Wlog

data Severity Source #

Severity is level of log message importance. It uniquely determines which messages to print.

Constructors

Debug

Debug messages

Info

Information

Notice

Important (more than average) information

Warning

General warnings

Error

General errors/severe errors

Instances

Bounded Severity Source # 
Enum Severity Source # 
Eq Severity Source # 
Ord Severity Source # 
Read Severity Source # 
Show Severity Source # 
Generic Severity Source # 

Associated Types

type Rep Severity :: * -> * #

Methods

from :: Severity -> Rep Severity x #

to :: Rep Severity x -> Severity #

ToJSON Severity Source # 
FromJSON Severity Source # 
SafeCopy Severity Source # 
type Rep Severity Source # 
type Rep Severity = D1 (MetaData "Severity" "System.Wlog.Severity" "log-warper-1.3.2-L4mhIB3c6wk5ZSf4HWCEjL" False) ((:+:) ((:+:) (C1 (MetaCons "Debug" PrefixI False) U1) (C1 (MetaCons "Info" PrefixI False) U1)) ((:+:) (C1 (MetaCons "Notice" PrefixI False) U1) ((:+:) (C1 (MetaCons "Warning" PrefixI False) U1) (C1 (MetaCons "Error" PrefixI False) U1))))

Logging Messages

Basic

logM Source #

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

debugM Source #

Arguments

:: String

Logger name

-> Text

Log message

-> IO () 

Log a message at Debug priority

infoM Source #

Arguments

:: String

Logger name

-> Text

Log message

-> IO () 

Log a message at Info priority

noticeM Source #

Arguments

:: String

Logger name

-> Text

Log message

-> IO () 

Log a message at Notice priority

warningM Source #

Arguments

:: String

Logger name

-> Text

Log message

-> IO () 

Log a message at Warning priority

errorM Source #

Arguments

:: String

Logger name

-> Text

Log message

-> IO () 

Log a message at Error priority

removeAllHandlers :: IO () Source #

Allow graceful shutdown. Release all opened fileshandlersetc.

traplogging Source #

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 -> (LogHandlerTag -> 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 #

Add handler to Logger. Returns a new Logger.

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.

setLevel :: Severity -> Logger -> Logger Source #

Sets the "level" of the Logger. Returns a new Logger object with the new level.

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.

updateGlobalLogger Source #

Arguments

:: String

Logger name

-> (Logger -> Logger)

Function to call

-> IO () 

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

setPrefix :: Maybe FilePath -> IO () Source #

Sets file prefix to LogInternalState.

retrieveLogContent :: MonadIO m => FilePath -> Maybe Int -> m [Text] Source #

Retrieves content of log file(s) given path (w/o _lcFilePrefix, as specified in your config). Example: there's component.log in config, but this function will return [component.log.122, component.log.123] if you want to. Content is file lines newest first.

FYI: this function is implemented to avoid the following problem: log-warper holds open handles to files, so trying to open log file for read would result in IOException.