eRPC Generator (erpcgen)
Rev. 1.12.0
NXP Semiconductors
|
Base logger class. More...
#include <Logging.hpp>
Public Types | |
enum | log_level_t { log_level_t::kUrgent, log_level_t::kError, log_level_t::kWarning, log_level_t::kInfo, log_level_t::kInfo2, log_level_t::kDebug, log_level_t::kDebug2, log_level_t::kInfo1, log_level_t::kDebug1 } |
Logging levels. More... | |
Public Member Functions | |
Logger () | |
Default constructor. | |
virtual | ~Logger () |
Destructor. | |
Logging levels | |
void | setFilterLevel (log_level_t level) |
Changes the logging level to level. | |
log_level_t | getFilterLevel () const |
Returns the current logging filter level. | |
void | setOutputLevel (log_level_t level) |
Changes the logging output level to level. | |
log_level_t | getOutputLevel () const |
Returns the current logging output level. | |
Logging | |
virtual void | log (const char *fmt,...) |
Log with format. | |
virtual void | log (const std::string &msg) |
Log a string object. | |
virtual void | log (log_level_t level, const char *fmt,...) |
Log with format at a specific output level. | |
virtual void | log (log_level_t level, const std::string &msg) |
Log a string output at a specific output level. | |
virtual void | log (const char *fmt, va_list args) |
Log with format using an argument list. | |
virtual void | log (log_level_t level, const char *fmt, va_list args) |
Log with format using an argument with a specific output level. More... | |
Protected Member Functions | |
virtual void | _log (Logger::log_level_t level, const char *msg)=0 |
The base pure virtual logging function implemented by subclasses. | |
Protected Attributes | |
log_level_t | m_filter |
The current logging filter level. | |
log_level_t | m_level |
The current log output level. | |
Base logger class.
There are two types of logging levels that are used by this class. First there is the filter level. Any log message that is assigned a level higher than the current filter level is discarded. Secondly there is the current output level. Log messages that do not have their own level use the current output level to determine if they should be shown or not.
The two methods setFilterLevel() and setOutputLevel() set the filter and default output logging levels, respectively. There are corresponding getter methods as well. Both the filter and output levels are initialized to #kInfo during object construction.
Most use of the logger classes is expected to be through the Log class. It provides static logging methods that call through to a global singleton logger instance. There is also a Log::SetOutputLevel utility class that makes it extremely easily to temporarily change the default output logging level.
Of all the overloaded log() methods in this class, none of them are really expected to be reimplemented by subclasses. Instead, there is the single protected _log() method that takes a simple string pointer. The other log methods all wind up calling _log(), so it provides a single point to override. In fact, _log() is pure virtual, so subclasses must implement it.
|
strong |
Logging levels.
|
virtual |
Log with format using an argument with a specific output level.
Allocates a temporary buffer which is used to hold the formatted string.