EduArt Sensor Ring Library 3.0.0
Loading...
Searching...
No Matches

Centralized class to collect all log messages and relay them to the registered observers. The Logger is implemented as a singleton. More...

#include <Logger.hpp>

Public Member Functions

 ~Logger ()=default
 Destructor.
subscription::Subscription subscribe (std::function< void(const LogVerbosity verbosity, const std::string &msg)> callback)
 Subscribe to log messages.
void unsubscribe (subscription::SubscriberToken token)
 Unsubscribe from log messages.
void log (const LogVerbosity verbosity, const std::string &msg) const
 Log a message that will be relayed to all registered observers.
void log (const LogVerbosity verbosity, const std::stringstream &msg) const
 Log a message that will be relayed to all registered observers.

Static Public Member Functions

static Logger * getInstance () noexcept
 Get a pointer to the instance of the Logger singleton.

Detailed Description

Centralized class to collect all log messages and relay them to the registered observers. The Logger is implemented as a singleton.

Member Function Documentation

◆ getInstance()

Logger * eduart::logger::Logger::getInstance ( )
staticnoexcept

Get a pointer to the instance of the Logger singleton.

Returns
Pointer to the Logger instance

◆ log() [1/2]

void eduart::logger::Logger::log ( const LogVerbosity verbosity,
const std::string & msg ) const

Log a message that will be relayed to all registered observers.

Parameters
[in]verbosityLog verbosity of the message
[in]msgLog message
Exceptions
Throwsstd::runtime_error when a message with LogVerbosity::Exception is logged

◆ log() [2/2]

void eduart::logger::Logger::log ( const LogVerbosity verbosity,
const std::stringstream & msg ) const

Log a message that will be relayed to all registered observers.

Parameters
[in]verbosityLog verbosity of the message
[in]msgLog message
Exceptions
Throwsstd::runtime_error when a message with LogVerbosity::Exception is logged

◆ subscribe()

subscription::Subscription eduart::logger::Logger::subscribe ( std::function< void(const LogVerbosity verbosity, const std::string &msg)> callback)

Subscribe to log messages.

Parameters
[in]callbackCallback function to be called when a log message is received
Returns
RAII Subscription that auto-cancels on destruction

◆ unsubscribe()

void eduart::logger::Logger::unsubscribe ( subscription::SubscriberToken token)

Unsubscribe from log messages.

Parameters
[in]tokenToken returned by subscribe

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