Class Logger

Class Documentation

class Logger

Public Types

enum class Severity

Values:

enumerator DEBUG
enumerator LOW
enumerator MID
enumerator HIGH
enumerator FATAL

Public Static Functions

static std::ostream &log()

Writes to the internal stream with no special formatting and without changing the severity level (which defaults to HIGH).

Returns

Reference to std::ostream (it enables to leverage the same interface as std::cout / cerr)

static std::ostream &info(Logger::Severity s = Logger::Severity::LOW)

Logs an information message (with bold [INFO] header).

Parameters

s – Message severity. Defaults to LOW.

Returns

Reference to std::ostream (it enables to leverage the same interface as std::cout / cerr)

static void info(Logger::Severity s, const char *fmt, ...)

Logs an information message (with bold [INFO] header).

Parameters
  • s – Message severity. Defaults to LOW.

  • fmt – Formatted string (printf-like)

  • ... – Values for the formatted string (printf-like)

static void info(const char *fmt, ...)

Logs an information message (with bold [INFO] header).

Parameters

fmt – Formatted string (printf-like)

static std::ostream &error(Logger::Severity s = Logger::Severity::HIGH)

Logs an error message (in red, with bold [ERROR] header).

Parameters

s – Message severity. Defaults to HIGH.

Returns

Reference to std::ostream (it enables to leverage the same interface as std::cout / cerr)

static void error(Logger::Severity s, const char *fmt, ...)

Logs an error message (with bold [error] header).

Parameters
  • s – Message severity. Defaults to HIGH.

  • fmt – Formatted string (printf-like)

  • ... – Values for the formatted string (printf-like)

static void error(const char *fmt, ...)

Logs an error message (with bold [error] header).

Parameters

fmt – Formatted string (printf-like)

static std::ostream &warning(Logger::Severity s = Logger::Severity::MID)

Logs a warning message (in yellow, with bold [warning] header).

Parameters

s – Message severity. Defaults to MEDIUM.

Returns

Reference to std::ostream (it enables to leverage the same interface as std::cout / cerr)

static void warning(Logger::Severity s, const char *fmt, ...)

Logs a warning message (with bold [warning] header).

Parameters
  • s – Message severity. Defaults to HIGH.

  • fmt – Formatted string (printf-like)

  • ... – Values for the formatted string (printf-like)

static void warning(const char *fmt, ...)

Logs a warning message (with bold [warning] header).

Parameters

fmt – Formatted string (printf-like)

static std::ostream &success(Logger::Severity s = Logger::Severity::LOW)

Logs a success message (in green, with bold [OK] header).

Parameters

s – Message severity. Defaults to LOW.

Returns

Reference to std::ostream (it enables to leverage the same interface as std::cout / cerr)

static void success(Logger::Severity s, const char *fmt, ...)

Logs a success message (with bold [success] header).

Parameters
  • s – Message severity. Defaults to HIGH.

  • fmt – Formatted string (printf-like)

  • ... – Values for the formatted string (printf-like)

static void success(const char *fmt, ...)

Logs an information message (with bold [INFO] header).

Parameters

fmt – Formatted string (printf-like)

static Endl &endl()

Closes the message and prints to screen.

static void SetVerbosityLevel(Logger::Severity s)

Sets the global verbosity level, i.e.

the minimum severity that a message must have in order to actually be printed.

static Logger::Severity GetVerbosityLevel()

Sets the global verbosity level, i.e.

the minimum severity that a message must have in order to actually be printed.

static void SetOnPrintCallback(std::function<void(char*, int, Logger::Severity)> f)

Sets the on print callback.

The user can customize the printing behavior by providing a custom function to the underlying logger.