Module CPM.ErrorLogger

Contains combinators for chaining IO actions that can fail and log messages.

Exported Datatypes


newtype ErrorLogger a

An error logging IO monad.

Known instances:


data LogEntry

A log entry.


data LogLevel

A log level.

Constructors:

  • Quiet :: LogLevel
  • Info :: LogLevel
  • Debug :: LogLevel
  • Error :: LogLevel
  • Critical :: LogLevel

Known instances:


Exported Functions


logLevelOf :: LogEntry -> LogLevel  Deterministic 

Further infos:
  • solution complete, i.e., able to compute all solutions

printLogEntry :: LogLevel -> LogEntry -> IO ()  Deterministic 

Renders a log entry to stderr.


levelGte :: LogLevel -> LogLevel -> Bool  Deterministic 

Compares two log levels.

Further infos:
  • solution complete, i.e., able to compute all solutions

logAt :: LogLevel -> String -> ErrorLogger ()  Deterministic 

Logs a message at a user-defined level.


logInfo :: String -> ErrorLogger ()  Deterministic 

Logs a message at the info level.


logDebug :: String -> ErrorLogger ()  Deterministic 

Logs a message at the debug level.


logError :: String -> ErrorLogger ()  Deterministic 

Logs a message at the error level.


logCritical :: String -> ErrorLogger ()  Deterministic 

Logs a message at the critical level.


putStrELM :: String -> ErrorLogger ()  Deterministic 

Prints a string in the ErrorLogger monad.


putStrLnELM :: String -> ErrorLogger ()  Deterministic 

Prints a line in the ErrorLogger monad.


fromErrorLogger :: LogLevel -> Bool -> ErrorLogger a -> IO a  Deterministic 

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

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  Deterministic 

Returns the current log level.


setLogLevel :: LogLevel -> ErrorLogger ()  Deterministic 

Sets the current log level.


getWithShowTime :: ErrorLogger Bool  Deterministic 

Returns the current time-showing mode.


setWithShowTime :: Bool -> ErrorLogger ()  Deterministic 

Sets the current time-showing mode.


liftIOEL :: IO a -> ErrorLogger a  Deterministic 

Lifts an IO action into the ErrorLogger monad.


tryEL :: Bool -> ErrorLogger a -> ErrorLogger (Either LogEntry a)  Deterministic 

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  Deterministic 

Executes a system command and shows the command as debug message.


execQuietCmd :: String -> String -> ErrorLogger Int  Deterministic 

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  Deterministic 

Executes an EL action with the current directory set to a specific directory.


inTempDirEL :: ErrorLogger a -> ErrorLogger a  Deterministic 

Executes an EL action with the current directory set to CPM's temporary directory.