Module CPM.ErrorLogger

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

Summary of exported operations:

logLevelOf :: LogEntry -> LogLevel   
getLogLevel :: IO LogLevel   
Gets the global log level.
setLogLevel :: LogLevel -> IO ()   
Sets the global log level.
setWithShowTime :: Bool -> IO ()   
Sets the "show time" information.
(|>=) :: IO ([LogEntry],Either LogEntry a) -> (a -> IO ([LogEntry],Either LogEntry b)) -> IO ([LogEntry],Either LogEntry b)   
Chains two actions passing the result from the first to the second.
(|>) :: IO ([LogEntry],Either LogEntry a) -> IO ([LogEntry],Either LogEntry b) -> IO ([LogEntry],Either LogEntry b)   
Chains two actions ignoring the result of the first.
(|->) :: IO ([LogEntry],Either LogEntry a) -> IO ([LogEntry],Either LogEntry b) -> IO ([LogEntry],Either LogEntry a)   
Chains two actions ignoring the result of the second.
(|>>) :: IO a -> IO ([LogEntry],Either LogEntry b) -> IO ([LogEntry],Either LogEntry b)   
Chains a standard IO action (where the result is ignored) with an error logger action.
mapEL :: (a -> IO ([LogEntry],Either LogEntry b)) -> [a] -> IO ([LogEntry],Either LogEntry [b])   
Maps an action over a list of values.
foldEL :: (a -> b -> IO ([LogEntry],Either LogEntry a)) -> a -> [b] -> IO ([LogEntry],Either LogEntry a)   
Folds a list of values using an action.
showLogEntry :: LogEntry -> IO ()   
Renders a log entry to stderr.
levelGte :: LogLevel -> LogLevel -> Bool   
Compares two log levels.
succeedIO :: a -> IO ([LogEntry],Either LogEntry a)   
Create an IO action that always succeeds.
failIO :: String -> IO ([LogEntry],Either LogEntry a)   
Create an IO action that always fails.
log :: LogLevel -> String -> IO ([LogEntry],Either LogEntry ())   
Create an IO action that logs a message.
infoMessage :: String -> IO ()   
Prints an info message in the standard IO monad.
debugMessage :: String -> IO ()   
Prints a debug message in the standard IO monad.
errorMessage :: String -> IO ()   
Prints an error message in the standard IO monad.
fromErrorLogger :: IO ([LogEntry],Either LogEntry a) -> IO a   
Transforms an error logger actions into a standard IO action.
showExecCmd :: String -> IO Int   
Executes a system command and show the command as debug message.
execQuietCmd :: (String -> String) -> IO Int   
Executes a parameterized system command.

Exported datatypes:


ErrorLogger

An error logger.

Type synonym: ErrorLogger a = ([LogEntry],Either LogEntry a)


LogEntry

A log entry.

Constructors:


LogLevel

A log level.

Constructors:

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

Exported operations:

logLevelOf :: LogEntry -> LogLevel   

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

getLogLevel :: IO LogLevel   

Gets the global log level. Messages below this level will not be printed.

setLogLevel :: LogLevel -> IO ()   

Sets the global log level. Messages below this level will not be printed.

setWithShowTime :: Bool -> IO ()   

Sets the "show time" information. If true, then timing information will be shown with every log information.

(|>=) :: IO ([LogEntry],Either LogEntry a) -> (a -> IO ([LogEntry],Either LogEntry b)) -> IO ([LogEntry],Either LogEntry b)   

Chains two actions passing the result from the first to the second.

Further infos:
  • defined as left-associative infix operator with precedence 0

(|>) :: IO ([LogEntry],Either LogEntry a) -> IO ([LogEntry],Either LogEntry b) -> IO ([LogEntry],Either LogEntry b)   

Chains two actions ignoring the result of the first.

Further infos:
  • defined as left-associative infix operator with precedence 0

(|->) :: IO ([LogEntry],Either LogEntry a) -> IO ([LogEntry],Either LogEntry b) -> IO ([LogEntry],Either LogEntry a)   

Chains two actions ignoring the result of the second.

Further infos:
  • defined as left-associative infix operator with precedence 0

(|>>) :: IO a -> IO ([LogEntry],Either LogEntry b) -> IO ([LogEntry],Either LogEntry b)   

Chains a standard IO action (where the result is ignored) with an error logger action.

Further infos:
  • defined as left-associative infix operator with precedence 0

mapEL :: (a -> IO ([LogEntry],Either LogEntry b)) -> [a] -> IO ([LogEntry],Either LogEntry [b])   

Maps an action over a list of values. Fails if one of the actions fails.

foldEL :: (a -> b -> IO ([LogEntry],Either LogEntry a)) -> a -> [b] -> IO ([LogEntry],Either LogEntry a)   

Folds a list of values using an action. Fails if one of the actions fails.

showLogEntry :: LogEntry -> IO ()   

Renders a log entry to stderr.

levelGte :: LogLevel -> LogLevel -> Bool   

Compares two log levels.

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

succeedIO :: a -> IO ([LogEntry],Either LogEntry a)   

Create an IO action that always succeeds.

failIO :: String -> IO ([LogEntry],Either LogEntry a)   

Create an IO action that always fails.

log :: LogLevel -> String -> IO ([LogEntry],Either LogEntry ())   

Create an IO action that logs a message.

infoMessage :: String -> IO ()   

Prints an info message in the standard IO monad.

debugMessage :: String -> IO ()   

Prints a debug message in the standard IO monad.

errorMessage :: String -> IO ()   

Prints an error message in the standard IO monad.

fromErrorLogger :: IO ([LogEntry],Either LogEntry a) -> IO a   

Transforms an error logger actions into a standard IO action. It shows all messages and, if the result is not available, exits with a non-zero code.

showExecCmd :: String -> IO Int   

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

execQuietCmd :: (String -> String) -> IO Int   

Executes a parameterized system command. The parameter is set to -q unless the LogLevel is Debug.