maliput
Logger Class Reference

Detailed Description

A logger class implementation.

Logger will dump all messages to a sink (SinkBase) which will be in charge of serializing the messages to the appropriate channel. By default, Sink implementation is used.

It provides six different log levels, logger::level , which can be filtered based on the severity of the message.

Comments about the design:

#include <include/maliput/common/logger.h>

Public Member Functions

 MALIPUT_NO_COPY_NO_MOVE_NO_ASSIGN (Logger)
 
 Logger ()=default
 
template<typename... Args>
void trace (const Args &... args)
 Log the message showing trace level prefix. More...
 
template<typename... Args>
void debug (const Args &... args)
 Log the message showing debug level prefix. More...
 
template<typename... Args>
void info (const Args &... args)
 Log the message showing info level prefix. More...
 
template<typename... Args>
void warn (const Args &... args)
 Log the message showing warning level prefix. More...
 
template<typename... Args>
void error (const Args &... args)
 Log the message showing error level prefix. More...
 
template<typename... Args>
void critical (const Args &... args)
 Log the message showing critical level prefix. More...
 
void set_sink (std::unique_ptr< common::SinkBase > sink)
 Set a sink. More...
 
SinkBaseget_sink ()
 Get the current sink. More...
 
std::string set_level (logger::level log_level)
 Sets the minimum level of messages to be logged. More...
 

Static Public Attributes

static constexpr int kNumberOfArguments {100}
 Indicates the maximum number of arguments that a single log command is able to process. More...
 

Related Functions

(Note that these are not member functions.)

std::string set_log_level (const std::string &level)
 Invokes maliput::log()->set_level(level). More...
 
common::Loggerlog ()
 Retrieve an instance of a logger to use for logger. More...
 

Constructor & Destructor Documentation

◆ Logger()

Logger ( )
default

Member Function Documentation

◆ get_sink()

SinkBase* get_sink ( )

Get the current sink.

Returns
A pointer to the current sink.

◆ MALIPUT_NO_COPY_NO_MOVE_NO_ASSIGN()

MALIPUT_NO_COPY_NO_MOVE_NO_ASSIGN ( Logger  )

◆ set_level()

std::string set_level ( logger::level  log_level)

Sets the minimum level of messages to be logged.

Parameters
log_levelMust be a level enum value from the level enumerations: trace, debug, info, warning, error, critical or off.
Returns
The string value of the previous log level.
See also
logger::kLevelToString.

◆ set_sink()

void set_sink ( std::unique_ptr< common::SinkBase sink)

Set a sink.

Parameters
sinkIs a SinkBase implementation.
Exceptions
common::assertion_errorWhen sink is nullptr.

Friends And Related Function Documentation

◆ log()

common::Logger * log ( )
related

Retrieve an instance of a logger to use for logger.

See Logger.

◆ set_log_level()

std::string set_log_level ( const std::string &  level)
related

Invokes maliput::log()->set_level(level).

See Logger.

Parameters
levelMust be a string from the level enumerations: trace, debug, info, warning, error, critical or off.
Returns
The string value of the previous log level.
Exceptions
std::out_of_rangeWhen level is not one of the predefined values.

Member Data Documentation

◆ kNumberOfArguments

constexpr int kNumberOfArguments {100}
staticconstexpr

Indicates the maximum number of arguments that a single log command is able to process.


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