eRPC Generator (erpcgen)  Rev. 1.12.0
NXP Semiconductors
Logger Class Referenceabstract

Base logger class. More...

#include <Logging.hpp>

Inheritance diagram for Logger:
StdoutLogger

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.
 

Detailed Description

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.

See also
Log

Member Enumeration Documentation

enum Logger::log_level_t
strong

Logging levels.

Enumerator
kUrgent 

The lowest level, for messages that must always be logged.

kError 

For fatal error messages.

kWarning 

For non-fatal warning messages.

kInfo 

The normal log level, for status messages.

kInfo2 

For verbose status messages.

kDebug 

For internal reporting.

kDebug2 

Highest log level; verbose debug logging.

kInfo1 

Alias for #kInfo.

kDebug1 

Alias for #kDebug.

Member Function Documentation

void Logger::log ( log_level_t  level,
const char *  fmt,
va_list  args 
)
virtual

Log with format using an argument with a specific output level.

Allocates a temporary buffer which is used to hold the formatted string.


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