text: {- arch-tag: Log handlers main definition Copyright (C) 2004-2006 Copyright : Copyright (C) 2004-2006 John Goerzen License : GNU LGPL, version 2.1 or above Maintainer : John Goerzen <jgoerzen@complete.org> Stability : provisional Portability: portable Definition of log handler support For some handlers, check out "System.Log.Handler.Simple" and "System.Log.Handler.Syslog". Please see "System.Log.Logger" for extensive documentation on the logging system. Written by John Goerzen, jgoerzen\@complete.org -} module System.Log.Handler(-- * Basic Types LogHandler(..) ) where import System.Log import System.IO {- | All log handlers should adhere to this. -} {- | This is the base class for the various log handlers. They should all adhere to this class. -} class LogHandler a where -- | Sets the log level. 'handle' will drop -- items beneath this level. setLevel :: a -> Priority -> a -- | Gets the current level. getLevel :: a -> Priority -- | Logs an event if it meets the requirements -- given by the most recent call to 'setLevel'. handle :: a -> LogRecord -> String-> IO () handle h (pri, msg) logname = if pri >= (getLevel h) then emit h (pri, msg) logname else return () -- | Forces an event to be logged regardless of -- the configured level. emit :: a -> LogRecord -> String -> IO () -- | Closes the logging system, causing it to close -- any open files, etc. close :: a -> IO ()