log-warper-1.8.7: 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.IOLogger

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 # 
type Rep Severity Source # 
type Rep Severity = D1 * (MetaData "Severity" "System.Wlog.Severity" "log-warper-1.8.7-2fs3r9lm3xFCwI6unumBhk" 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

:: MonadIO m 
=> LoggerName

Name of the logger to use

-> Severity

Severity of this message

-> Text

The log text itself

-> m () 

Log a message using the given logger at a given priority.

Utility Functions

removeAllHandlers :: MonadIO m => m () Source #

Allow graceful shutdown. Release all opened fileshandlersetc.

Logger Manipulation

Finding ∨ Creating Loggers

getLogger :: MonadIO m => LoggerName -> m 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 :: MonadIO m => m Logger Source #

Returns the root logger.

rootLoggerName :: LoggerName 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 Severities Source #

Returns the "level" of the logger. Items beneath this level will be ignored.

setLevel :: Severities -> 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.

Severity settings

setSeverities :: MonadIO m => LoggerName -> Severities -> m () Source #

Set severities for given logger. By default parent's severities are used.

setSeveritiesMaybe :: MonadIO m => LoggerName -> Maybe Severities -> m () Source #

Set or clear severities.

Saving Your Changes

saveGlobalLogger :: MonadIO m => Logger -> m () Source #

Updates the global record for the given logger to take into account any changes you may have made.

updateGlobalLogger Source #

Arguments

:: MonadIO m 
=> LoggerName

Logger name

-> (Logger -> Logger)

Function to call

-> m () 

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 :: MonadIO m => Maybe FilePath -> m () 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.