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.
fromELM :: ErrorLoggerIO a -> IO ([LogEntry],Either LogEntry a)   
Transforms an ErrorLoggerIO monad action into an IO action.
toELM :: IO ([LogEntry],Either LogEntry a) -> ErrorLoggerIO a   
Transforms an IO action into an ErrorLoggerIO monad action.
execIO :: IO a -> ErrorLoggerIO a   
Executes an IO action in the ErrorLoggerIO monad.
putStrELM :: String -> ErrorLoggerIO ()   
Prints a string in the ErrorLoggerIO monad.
putStrLnELM :: String -> ErrorLoggerIO ()   
Prints a line in the ErrorLoggerIO monad.
runELM :: ErrorLoggerIO a -> IO a   
Runs an ErrorLoggerIO monad action as an IO action.
(|>=) :: IO ([LogEntry],Either LogEntry a) -> (a -> IO ([LogEntry],Either LogEntry b)) -> IO ([LogEntry],Either LogEntry b)   
(|>) :: IO ([LogEntry],Either LogEntry a) -> IO ([LogEntry],Either LogEntry b) -> IO ([LogEntry],Either LogEntry b)   
Chains two actions ignoring the result of the first.
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.
failELM :: String -> ErrorLoggerIO a   
Create an ErrorLoggerIO action that always fails with a message.
logMsg :: LogLevel -> String -> ErrorLoggerIO ()   
Creates an IO action that logs a message.
log :: LogLevel -> String -> IO ([LogEntry],Either LogEntry ())   
Creates 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 action 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

ErrorLoggerIO

Datatype to define the ErrorLoggerIO monad.

Constructors:


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.

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

Transforms an ErrorLoggerIO monad action into an IO action.

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

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

Transforms an IO action into an ErrorLoggerIO monad action.

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

execIO :: IO a -> ErrorLoggerIO a   

Executes an IO action in the ErrorLoggerIO monad.

putStrELM :: String -> ErrorLoggerIO ()   

Prints a string in the ErrorLoggerIO monad.

putStrLnELM :: String -> ErrorLoggerIO ()   

Prints a line in the ErrorLoggerIO monad.

runELM :: ErrorLoggerIO a -> IO a   

Runs an ErrorLoggerIO monad action as an IO action. Shows all messages and exit with status 1 if an error occurred.

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

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

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.

failELM :: String -> ErrorLoggerIO a   

Create an ErrorLoggerIO action that always fails with a message.

logMsg :: LogLevel -> String -> ErrorLoggerIO ()   

Creates an IO action that logs a message.

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

Creates 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 action 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.