Class LoggerClass

Class Documentation

class LoggerClass

Logger class.

Public Types

typedef std::shared_ptr<LoggerClass> Ptr
typedef std::function<void(char*, int, Logger::Severity)> OnPrintCallback

Public Functions

LoggerClass(std::string logger_name)
LoggerClass(std::string logger_name, OnPrintCallback f)
~LoggerClass()
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)

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)

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)

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

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

Parameters

fmt – Formatted string (printf-like)

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)

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)

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

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

Parameters

fmt – Formatted string (printf-like)

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)

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

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

Parameters
  • s – Message severity. Defaults to MEDIUM.

  • fmt – Formatted string (printf-like)

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

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

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

Parameters

fmt – Formatted string (printf-like)

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)

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

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

Parameters
  • s – Message severity. Defaults to LOW.

  • fmt – Formatted string (printf-like)

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

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

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

Parameters

fmt – Formatted string (printf-like)

Endl &endl()

Closes the message and prints to screen.

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.

Logger::Severity getVerbosityLevel() const

Sets the global verbosity level, i.e.

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

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.

Public Static Functions

static void DefaultOnPrint(char*, int, Logger::Severity)

Friends

friend class Endl
friend class Logger