mitteLib
Loading...
Searching...
No Matches
mlab::suppress_log Struct Reference

A utility class to contextually enable/disable some of ESP32 log levels. This class is RAII, so it will restore the original logging level when destroyed. More...

#include <log.hpp>

Public Member Functions

 suppress_log ()=default
 
 suppress_log (std::initializer_list< const char * > tags)
 
 suppress_log (log_level min_level, std::initializer_list< const char * > tags)
 
void suppress ()
 
void restore ()
 
 ~suppress_log ()
 
Move semantics
 suppress_log (suppress_log const &)=delete
 
 suppress_log (suppress_log &&other) noexcept
 
suppress_logoperator= (suppress_log const &other)=delete
 
suppress_logoperator= (suppress_log &&other) noexcept
 

Public Attributes

std::vector< std::pair< const char *, log_level > > tag_log_lev {}
 
log_level min_level = log_level::none
 
bool is_suppressed = false
 

Detailed Description

A utility class to contextually enable/disable some of ESP32 log levels. This class is RAII, so it will restore the original logging level when destroyed.

Note
We can only reduce the log level, not increase it. Log levels that are not enabled at ESP32 configuration level are not available, as the statements are simply not compiled.

Constructor & Destructor Documentation

◆ suppress_log() [1/5]

mlab::suppress_log::suppress_log ( )
default

Default-constructor, does nothing.

◆ suppress_log() [2/5]

mlab::suppress_log::suppress_log ( std::initializer_list< const char * > tags)

Suppresses instantly and entirely all the specified tags

Parameters
tagsList of log tags, e.g. {"DESFIRE", "PN532"}.

◆ suppress_log() [3/5]

mlab::suppress_log::suppress_log ( log_level min_level,
std::initializer_list< const char * > tags )

Suppresses all the specified tags, allowing only logging at min_level and above.

Parameters
min_levelMinimum level that is echoed.
tagsList of log tags, e.g. {"DESFIRE", "PN532"}.

◆ suppress_log() [4/5]

mlab::suppress_log::suppress_log ( suppress_log const & )
delete

◆ suppress_log() [5/5]

mlab::suppress_log::suppress_log ( suppress_log && other)
noexcept

◆ ~suppress_log()

mlab::suppress_log::~suppress_log ( )

Calls restore before exiting.

Member Function Documentation

◆ operator=() [1/2]

suppress_log & mlab::suppress_log::operator= ( suppress_log && other)
noexcept

◆ operator=() [2/2]

suppress_log & mlab::suppress_log::operator= ( suppress_log const & other)
delete

◆ restore()

void mlab::suppress_log::restore ( )

Manually restores all teh tags in tag_log_lev to the level they had at the constrution of the object.

◆ suppress()

void mlab::suppress_log::suppress ( )

Manually suppresses all the tags in tag_log_lev to the minimum echoed level min_level.

Member Data Documentation

◆ is_suppressed

bool mlab::suppress_log::is_suppressed = false

A boolean representing whether the suppression is active at the current moment in time.

◆ min_level

log_level mlab::suppress_log::min_level = log_level::none

The minimum level that is echoed.

◆ tag_log_lev

std::vector<std::pair<const char *, log_level> > mlab::suppress_log::tag_log_lev {}

A list of the log tags and their original log level.


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