Contains combinators for chaining IO actions that can fail and log messages.
newtype ErrorLogger a
An error logging IO monad.
Known instances:
Functor ErrorLogger
Applicative ErrorLogger
Alternative ErrorLogger
Monad ErrorLogger
MonadFail ErrorLogger
data LogEntry
A log entry.
data LogLevel
A log level.
Constructors:
Quiet
:: LogLevel
Info
:: LogLevel
Debug
:: LogLevel
Error
:: LogLevel
Critical
:: LogLevel
Known instances:
logLevelOf
:: LogEntry -> LogLevel
printLogEntry
:: LogLevel -> LogEntry -> IO ()
Renders a log entry to stderr.
levelGte
:: LogLevel -> LogLevel -> Bool
Compares two log levels.
logAt
:: LogLevel -> String -> ErrorLogger ()
Logs a message at a user-defined level.
logInfo
:: String -> ErrorLogger ()
Logs a message at the info level.
logDebug
:: String -> ErrorLogger ()
Logs a message at the debug level.
logError
:: String -> ErrorLogger ()
Logs a message at the error level.
logCritical
:: String -> ErrorLogger ()
Logs a message at the critical level.
putStrELM
:: String -> ErrorLogger ()
Prints a string in the ErrorLogger
monad.
putStrLnELM
:: String -> ErrorLogger ()
Prints a line in the ErrorLogger
monad.
fromErrorLogger
:: LogLevel -> Bool -> ErrorLogger a -> IO a
Transforms an error logger action into a standard IO action. It shows all messages and, if the result is not available, exits with a non-zero code. The first argument specifies the logging level for messages. If the second argument is true, timings are shown in the messages.
fromErrorLoggerMsgs
:: LogLevel -> ErrorLogger a -> IO (String, Maybe a)
Transforms an error logger action into a standard IO action
where all messages and the result (or Nothing
in case of a failure)
are returned.
The first argument specifies the logging level for messages.
getLogLevel
:: ErrorLogger LogLevel
Returns the current log level.
setLogLevel
:: LogLevel -> ErrorLogger ()
Sets the current log level.
getWithShowTime
:: ErrorLogger Bool
Returns the current time-showing mode.
setWithShowTime
:: Bool -> ErrorLogger ()
Sets the current time-showing mode.
liftIOEL
:: IO a -> ErrorLogger a
Lifts an IO action into the ErrorLogger
monad.
tryEL
:: Bool -> ErrorLogger a -> ErrorLogger (Either LogEntry a)
Tries to execute an EL action and returns either an error that
occurred or the value. If the first argument is True
, the execution
will run quietly.
showExecCmd
:: String -> ErrorLogger Int
Executes a system command and shows the command as debug message.
execQuietCmd
:: String -> String -> ErrorLogger Int
Executes a command depending on the verbosity mode.
If the log level is not Debug
, the first (quiet) command is executed,
otherwise the second (more verbose) command is executed.
inDirectoryEL
:: String -> ErrorLogger a -> ErrorLogger a
Executes an EL action with the current directory set to a specific directory.
inTempDirEL
:: ErrorLogger a -> ErrorLogger a
Executes an EL action with the current directory set to CPM's temporary directory.