AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
anch::log::Logger Class Reference

#include <logger.hpp>

Collaboration diagram for anch::log::Logger:

Public Member Functions

 Logger (const std::string &name, const anch::log::Level level, const std::vector< anch::log::Writer * > &writers)
virtual ~Logger ()
template<typename T, typename... Q>
void trace (const T &value, const Q &... values) const noexcept
template<typename T, typename... Q>
void debug (const T &value, const Q &... values) const noexcept
template<typename T, typename... Q>
void info (const T &value, const Q &... values) const noexcept
template<typename T, typename... Q>
void warn (const T &value, const Q &... values) const noexcept
template<typename T, typename... Q>
void error (const T &value, const Q &... values) const noexcept
template<typename T, typename... Q>
void fatal (const T &value, const Q &... values) const noexcept
bool isEnabled (const anch::log::Level &level) const noexcept
void write (const anch::log::Level &level, const std::string &message) const noexcept

Detailed Description

Logger class.
Aims to provide logging facilities.

Logging levels are:

  • TRACE
  • DEBUG
  • INFO
  • WARN
  • ERROR
  • FATAL
Author
Vincent Lachenal

Constructor & Destructor Documentation

◆ Logger()

anch::log::Logger::Logger ( const std::string & name,
const anch::log::Level level,
const std::vector< anch::log::Writer * > & writers )

Logger constructor.

Parameters
nameLogger name
levelThe logging level to set
writersThe writers list

◆ ~Logger()

virtual anch::log::Logger::~Logger ( )
virtual

Logger destructor

Member Function Documentation

◆ debug()

template<typename T, typename... Q>
void anch::log::Logger::debug ( const T & value,
const Q &... values ) const
noexcept

Concatenate message and log it in DEBUG level.
Removed at compile time when DEBUG is lower than MIN_LEVEL ( ANCH_LOG_MIN_LEVEL ).
Values are always evaluated.

Parameters
valueThe first value of the message to concatenate
valuesThe other values of the message to concatenate

◆ error()

template<typename T, typename... Q>
void anch::log::Logger::error ( const T & value,
const Q &... values ) const
noexcept

Concatenate message and log it in ERROR level.
Removed at compile time when ERROR is lower than MIN_LEVEL ( ANCH_LOG_MIN_LEVEL ).
Values are always evaluated.

Parameters
valueThe first value of the message to concatenate
valuesThe other values of the message to concatenate

◆ fatal()

template<typename T, typename... Q>
void anch::log::Logger::fatal ( const T & value,
const Q &... values ) const
noexcept

Concatenate message and log it in FATAL level.
Removed at compile time when FATAL is lower than MIN_LEVEL ( ANCH_LOG_MIN_LEVEL ).
Values are always evaluated.

Parameters
valueThe first value of the message to concatenate
valuesThe other values of the message to concatenate

◆ info()

template<typename T, typename... Q>
void anch::log::Logger::info ( const T & value,
const Q &... values ) const
noexcept

Concatenate message and log it in INFO level.
Removed at compile time when INFO is lower than MIN_LEVEL ( ANCH_LOG_MIN_LEVEL ).
Values are always evaluated.

Parameters
valueThe first value of the message to concatenate
valuesThe other values of the message to concatenate

◆ isEnabled()

bool anch::log::Logger::isEnabled ( const anch::log::Level & level) const
noexcept

Check if a message in this level will be written by this logger

Parameters
levelThe message level
Returns
true when level is greater or equal to the logger level and the logger has writers
Since
0.2

◆ trace()

template<typename T, typename... Q>
void anch::log::Logger::trace ( const T & value,
const Q &... values ) const
noexcept

Concatenate message and log it in TRACE level.
Removed at compile time when TRACE is lower than MIN_LEVEL ( ANCH_LOG_MIN_LEVEL ).
Values are always evaluated.

Parameters
valueThe first value of the message to concatenate
valuesThe other values of the message to concatenate

◆ warn()

template<typename T, typename... Q>
void anch::log::Logger::warn ( const T & value,
const Q &... values ) const
noexcept

Concatenate message and log it in WARN level.
Removed at compile time when WARN is lower than MIN_LEVEL ( ANCH_LOG_MIN_LEVEL ).
Values are always evaluated.

Parameters
valueThe first value of the message to concatenate
valuesThe other values of the message to concatenate

◆ write()

void anch::log::Logger::write ( const anch::log::Level & level,
const std::string & message ) const
noexcept

Write an already formatted message on every writer.
The level is not checked: check it with isEnabled before formatting the message.
Writer errors are ignored: a writer error does not prevent other writers to log.

Parameters
levelThe message level
messageThe message to write
Since
0.2

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