|
|
|
|
|
Description |
Manages an error log with proper locking. has a number of useful routines for detecting
and reporting erronious conditions.
|
|
Synopsis |
|
|
|
|
Log handling
|
|
data LogLevel |
Constructors | LogEmergency | | LogAlert | | LogCritical | | LogError | | LogWarning | | LogNotice | | LogInfo | | LogDebug | |
| Instances | |
|
|
withErrorLog |
:: String | filename of log
| -> IO a | action to execute with logging to file
| -> IO a | | open file for logging and run action, with errors being logged to the file.
This will reinstall the old errorlog handle when it finishes, by default stderr
is used and this routine need not be called unless you wish to log somewhere else.
the filename consisting of a single dash is treated specially and sets the errorlog
to stderr. note, that while the errorlog will function properly with concurrent
applications, a single errorlog is shared by all threads.
|
|
|
withStartEndEntrys |
:: String | title to use in log entries
| -> IO a | action to execute
| -> IO a | | add entries to log at the start and end of action with timestamp.
If the action throws an exception, it will be logged along with the
exit entry.
|
|
|
withErrorMessage :: String -> IO a -> IO a |
run an action, printing an error message to the log if it ends with an exception.
this is similar to withStartEndEntrys but only adds an entry on error.
|
|
setLogLevel :: LogLevel -> IO LogLevel |
sets log level to new value, returns old log level.
|
|
setErrorLogPutStr :: (Handle -> String -> IO ()) -> IO () |
set routine with same signature as hPutStr to use for writing to log.
useful for charset conversions which might be necisarry. By default the
haskell 98 hPutStr is used.
|
|
adding log entries
|
|
putLogLn :: String -> IO () |
place log entry, normalize string to always have a single 'n' at the end
of the string. A single log entry is created for each putLogLn, do not
split entrys among calls to this function.
|
|
putLog :: LogLevel -> String -> IO () |
create log entry with given loglevel. entry is normalized as in putLogLn.
|
|
putLogException :: String -> Exception -> IO () |
|
annotating exceptions
|
|
emapM :: (Exception -> Exception) -> IO a -> IO a |
transform an exception with a function.
|
|
eannM :: String -> IO a -> IO a |
annotates an exception using emapM, the original
type of the error cannot be recovered so this should only be used
if the exception is not meant to be caught later.
|
|
exception-aware composition
|
|
retry |
:: Float | number of seconds to pause between trys
| -> String | string to annotate log entries with when retrying
| -> IO a | action to retry
| -> IO a | | Retry an action untill it succeeds.
|
|
|
first :: [IO a] -> IO a |
return the first non-excepting action. if all actions throw exceptions,
the last actions exception is rethrown.
|
|
tryMap :: (a -> b) -> [a] -> IO [b] |
|
tryMapM :: (a -> IO b) -> [a] -> IO [b] |
|
trySeveral :: [IO a] -> IO a |
concurrently try several IO actions, returning the result of the first to finish.
if all actions throw exceptions, one is passed on non-deterministically
|
|
random functions
|
|
attempt :: IO a -> IO () |
attempt an action, add a log entry with the exception if it
fails
|
|
ioElse :: IO a -> IO a -> IO a |
|
indent :: Int -> String -> String |
|
Produced by Haddock version 0.8 |