OSFI-C++  3.10.0
OpenSF Integration Library
Logger Class Reference

#include <Logger.h>

Static Public Member Functions

static void error (const string &message)
 
static void warning (const string &message)
 
static void info (const string &message)
 
static void debug (const string &message)
 
static ostream & getErrorStream ()
 
static ostream & getDebugStream ()
 
static ostream & getInfoStream ()
 
static ostream & getWarningStream ()
 
static void progress (int step, int nSteps)
 
static void finishExecution (int errorCode)
 
static void qualityReport (const string &name, double value)
 
static void qualityReport (const string &name, const string &value)
 
static ostream & getQualityStream ()
 
static bool isDebugging ()
 
static bool isColored ()
 

Detailed Description

Procedures for presenting messages in the standard output in a format that can later be interpreted by openSF and others following the E2E-ICD.

EHLog formats the logging messages as follows:

<message> ::= (<progress> | <log>) <EOL>
<progress> ::= “Progress” <whitespaces> <delimiter> <whitespaces> <progress_body>
<delimiter> ::= “|”
<progress_body> ::= <integer> “ of ” <whitespace> <integer>
<log> ::= <type> <whitespaces> <delimiter> <whitespaces> <text>
<type> ::= “Error” | “Warning” | “Info” | “Debug”
<white_spaces> ::= (“ “)+

This format defines five different types of messages:

  • Information. This is a message raised by the model describing a harmless event, giving knowledge to the user. Model execution should continue with no interruptions.
  • Warning. The model has detected a non-fatal error or situation that may cause a fatal error. This is a harmless event, thus, the execution should continue with no interruption.
  • Error. A fatal error has happened in the model execution and the model itself informs the user about it, so the model has time to “gracefully” close the execution.
  • Debug. Detailed information of the model execution given to the user. Information is intended to lead the user (or model developer) upon fixing a problem. This is a harmless event so model execution should continue with no interruptions.
  • Progress. Numerical information on the amount of model execution performed.

Logger class presents debug messages only if an environment variables named “DEBUG_MODE” is defined and set as “On” in the model execution context. Logger also provides a way to finish the model execution (after a fatal error or at the expected end of the execution) and return a non-zero code to the operating system.

Member Function Documentation

◆ debug()

static void Logger::debug ( const string &  message)
static

Shows a formatted debug message, if the environment variable "DEBUG_MODE" is equal to "On". First time this function is called, checks the declaration of that variable. If it is not declared, presents a warning message and assumes it as "Off".

Parameters
message- text of the message

◆ error()

static void Logger::error ( const string &  message)
static

Shows a formatted error message.

Parameters
message- text of the message

◆ finishExecution()

static void Logger::finishExecution ( int  errorCode)
static

Shows an information message and exits the program execution with an specific error code.

Parameters
errorCode- Code of error to exit with.
Warning
This call never returns and causes termination of the program.

◆ getDebugStream()

static ostream& Logger::getDebugStream ( )
static

Returns the output stream used to show debugging messages. Developers can use this function as a convenient method for showing complex data types. Returns a "null stream" is not in debug mode, implying that nothing is written on output stream.

◆ getErrorStream()

static ostream& Logger::getErrorStream ( )
static

Returns the output stream used to show error messages. Developers can use this function as a convenient method for showing complex data types.

◆ getInfoStream()

static ostream& Logger::getInfoStream ( )
static

Returns the output stream used to show information messages. Developers can use this function as a convenient method for showing complex data types.

◆ getQualityStream()

static ostream& Logger::getQualityStream ( )
static

Returns the output stream used to show quality messages. Developers can use this function as a convenient method for showing complex data types.

◆ getWarningStream()

static ostream& Logger::getWarningStream ( )
static

Returns the output stream used to show warning messages. Developers can use this function as a convenient method for showing complex data types.

◆ info()

static void Logger::info ( const string &  message)
static

Shows a formatted information message.

Parameters
message- text of the message

◆ isColored()

static bool Logger::isColored ( )
static

Checks if the system is in color mode. LOG_COLOR if ON the OSFI logs are colored.

  • Error : Red
  • Warning: Yellow
  • Progress: Cyan
  • Info: Green

◆ isDebugging()

static bool Logger::isDebugging ( )
static

Checks if the system is in debug mode.

◆ progress()

static void Logger::progress ( int  step,
int  nSteps 
)
static

Shows a formatted progress message.

Parameters
step- current step number
nSteps- maximum number of steps.

◆ qualityReport() [1/2]

static void Logger::qualityReport ( const string &  name,
const string &  value 
)
static

Shows a formatted message reporting a quality indicator

Parameters
name- Name of the quality indicator
value- String associated to the quality indicator pointed by name

◆ qualityReport() [2/2]

static void Logger::qualityReport ( const string &  name,
double  value 
)
static

Shows a formated message reporting a quality indicator

Parameters
name- Name of the quality indicator
value- Double associated to the quality indicator pointed by name

◆ warning()

static void Logger::warning ( const string &  message)
static

Shows a formatted warning message.

Parameters
message- text of the message

The documentation for this class was generated from the following file: