XBotInterface  2.4.1
XBotInterface provides a generic API to model and control a robot.
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
XBot::LoggerClass Class Reference

Logger class. More...

#include <RtLog.hpp>

+ Collaboration diagram for XBot::LoggerClass:

Public Types

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

Public Member 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). More...
 
std::ostream & info (Logger::Severity s=Logger::Severity::LOW)
 Logs an information message (with bold [INFO] header). More...
 
void info (Logger::Severity s, const char *fmt,...)
 Logs an information message (with bold [INFO] header). More...
 
void info (const char *fmt,...)
 Logs an information message (with bold [INFO] header). More...
 
std::ostream & error (Logger::Severity s=Logger::Severity::HIGH)
 Logs an error message (in red, with bold [ERROR] header). More...
 
void error (Logger::Severity s, const char *fmt,...)
 Logs an error message (with bold [ERROR] header). More...
 
void error (const char *fmt,...)
 Logs an error message (with bold [ERROR] header). More...
 
std::ostream & warning (Logger::Severity s=Logger::Severity::MID)
 Logs a warning message (in yellow, with bold [WARNING] header). More...
 
void warning (Logger::Severity s, const char *fmt,...)
 Logs an warning message (with bold [warning] header). More...
 
void warning (const char *fmt,...)
 Logs an warning message (with bold [warning] header). More...
 
std::ostream & success (Logger::Severity s=Logger::Severity::LOW)
 Logs a success message (in green, with bold [OK] header). More...
 
void success (Logger::Severity s, const char *fmt,...)
 Logs a success message (with bold [success] header). More...
 
void success (const char *fmt,...)
 Logs a success message (with bold [success] header). More...
 
Endlendl ()
 Closes the message and prints to screen. More...
 
void setVerbosityLevel (Logger::Severity s)
 Sets the global verbosity level, i.e. More...
 
Logger::Severity getVerbosityLevel () const
 Sets the global verbosity level, i.e. More...
 
void setOnPrintCallback (std::function< void(char *, int, Logger::Severity)> f)
 Sets the on print callback. More...
 

Static Public Member Functions

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

Friends

class Endl
 
class Logger
 

Detailed Description

Logger class.

Member Typedef Documentation

◆ OnPrintCallback

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

◆ Ptr

typedef std::shared_ptr<LoggerClass> XBot::LoggerClass::Ptr

Constructor & Destructor Documentation

◆ LoggerClass() [1/2]

XBot::LoggerClass::LoggerClass ( std::string  logger_name)

◆ LoggerClass() [2/2]

XBot::LoggerClass::LoggerClass ( std::string  logger_name,
OnPrintCallback  f 
)

◆ ~LoggerClass()

XBot::LoggerClass::~LoggerClass ( )

Member Function Documentation

◆ DefaultOnPrint()

void XBot::LoggerClass::DefaultOnPrint ( char *  msg,
int  n_chars,
Logger::Severity  s 
)
static

◆ endl()

Endl & XBot::LoggerClass::endl ( )

Closes the message and prints to screen.

◆ error() [1/3]

void XBot::LoggerClass::error ( const char *  fmt,
  ... 
)

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

Parameters
fmtFormatted string (printf-like)

◆ error() [2/3]

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

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

Parameters
sMessage severity. Defaults to HIGH.
fmtFormatted string (printf-like)
...Values for the formatted string (printf-like)

◆ error() [3/3]

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

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

Parameters
sMessage severity. Defaults to HIGH.
Returns
Reference to std::ostream (it enables to leverage the same interface as std::cout / cerr)

◆ getVerbosityLevel()

Logger::Severity XBot::LoggerClass::getVerbosityLevel ( ) const

Sets the global verbosity level, i.e.

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

◆ info() [1/3]

void XBot::LoggerClass::info ( const char *  fmt,
  ... 
)

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

Parameters
fmtFormatted string (printf-like)

◆ info() [2/3]

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

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

Parameters
sMessage severity. Defaults to LOW.
fmtFormatted string (printf-like)
...Values for the formatted string (printf-like)

◆ info() [3/3]

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

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

Parameters
sMessage severity. Defaults to LOW.
Returns
Reference to std::ostream (it enables to leverage the same interface as std::cout / cerr)

◆ log()

std::ostream & XBot::LoggerClass::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)

◆ setOnPrintCallback()

void XBot::LoggerClass::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.

◆ setVerbosityLevel()

void XBot::LoggerClass::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.

◆ success() [1/3]

void XBot::LoggerClass::success ( const char *  fmt,
  ... 
)

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

Parameters
fmtFormatted string (printf-like)

◆ success() [2/3]

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

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

Parameters
sMessage severity. Defaults to LOW.
fmtFormatted string (printf-like)
...Values for the formatted string (printf-like)

◆ success() [3/3]

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

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

Parameters
sMessage severity. Defaults to LOW.
Returns
Reference to std::ostream (it enables to leverage the same interface as std::cout / cerr)

◆ warning() [1/3]

void XBot::LoggerClass::warning ( const char *  fmt,
  ... 
)

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

Parameters
fmtFormatted string (printf-like)

◆ warning() [2/3]

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

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

Parameters
sMessage severity. Defaults to MEDIUM.
fmtFormatted string (printf-like)
...Values for the formatted string (printf-like)

◆ warning() [3/3]

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

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

Parameters
sMessage severity. Defaults to MEDIUM.
Returns
Reference to std::ostream (it enables to leverage the same interface as std::cout / cerr)

Friends And Related Function Documentation

◆ Endl

friend class Endl
friend

◆ Logger

friend class Logger
friend

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