modm API documentation
Logging

Namespaces

 modm::log
 Logger.
 

Classes

class  modm::log::DefaultStyle
 This is an empty style More...
 
class  modm::log::Logger
 Interface to the Logger More...
 
class  modm::log::Prefix< T, STYLE >
 Add a prefix to the log message More...
 
class  modm::log::StdColour< TEXT, BACKGROUND, STYLE >
 This style colours the given stream in the color given by the template argument More...
 
class  modm::log::Style< STYLE >
 This is the interface to all style-classes of the logger More...
 
class  modm::log::StyleWrapper< STYLE >
 Wrapper to use the Style as a IODevice in the Logger More...
 

Macros

#define MODM_LOG_LEVEL   modm::log::DEBUG
 Default log level. More...
 
#define MODM_LOG_OFF
 Turn off messages print. More...
 
#define MODM_LOG_DEBUG
 Output stream for debug messages. More...
 
#define MODM_LOG_INFO
 Output stream for info messages. More...
 
#define MODM_LOG_WARNING
 Output stream for warnings. More...
 
#define MODM_LOG_ERROR
 Output stream for error messages. More...
 
#define FILENAME
 Filename of the current file. More...
 
#define MODM_FILE_INFO
 String containing the filename and the current line. More...
 

Enums

enum  modm::log::Level {
  DEBUG, INFO, WARNING, ERROR,
  DISABLED
}
 Log levels. More...
 

Detailed Description

lbuild module: modm:debug

The modm::log::Logger uses a modm::IOStream to read messages and write them to a given output device.

Write a log message with streams:

MODM_LOG_DEBUG << "i=" << i << ", y=" << y << modm::flush;

The name of the stream represents the log level of the message. Available are:

A log message can also be generated separately:

int a[3] = {1,2,3};
MODM_LOG_DEBUG << "a = ";
for(int i = 0; i < sizeof(a); ++i) {
MODM_LOG_DEBUG << a[i] << ", ";
}

Flow of a call

This is to give an estimation how many resources a call of the logger use. All considerations are for a PC program.

The given call is:

MODM_LOG_DEBUG << 123456;

The macro resolves to:

if (MODM_LOG_LEVEL <= modm::log::DEBUG)

In sum there are two nested method calls with one of them being virtual.

Macro Definition Documentation

#define FILENAME

Filename of the current file.

In contrast to FILE the path to the file is omitted (if this feature is available, otherwise this macro will resolve to FILE).

#define MODM_FILE_INFO

String containing the filename and the current line.

Will generate something like:

"file.cpp (123) >> "

This can be very useful the track the origin of log-messages:

<< "... something has happened ..."

This will result into:

file.cpp (123) >> ... something has happened ...
#define MODM_LOG_DEBUG
Value:
if (MODM_LOG_LEVEL > modm::log::DEBUG){}
Logger debug
log device to take messages on DEBUG level
#define MODM_LOG_LEVEL
Default log level.
Definition: level.hpp:58

Output stream for debug messages.

#define MODM_LOG_ERROR
Value:
if (MODM_LOG_LEVEL > modm::log::ERROR){}
Logger error
log device to take messages on ERROR level
#define MODM_LOG_LEVEL
Default log level.
Definition: level.hpp:58

Output stream for error messages.

#define MODM_LOG_INFO
Value:
if (MODM_LOG_LEVEL > modm::log::INFO){}
Logger info
log device to take messages on INFO level
#define MODM_LOG_LEVEL
Default log level.
Definition: level.hpp:58

Output stream for info messages.

#define MODM_LOG_LEVEL   modm::log::DEBUG

Default log level.

Define to set the level of the logging to a defined value for each file. To change the logging level in a source file use #undef

#undef MODM_LOG_LEVEL
#define MODM_LOG_LEVEL modm::log::INFO

DEBUG < INFO < WARNING < ERROR < DISABLED

#define MODM_LOG_OFF
Value:
if ( true ){}
Logger debug
log device to take messages on DEBUG level

Turn off messages print.

#define MODM_LOG_WARNING
Value:
if (MODM_LOG_LEVEL > modm::log::WARNING){}
Logger warning
log device to take messages on WARNING level
#define MODM_LOG_LEVEL
Default log level.
Definition: level.hpp:58

Output stream for warnings.

Enumeration Type Documentation

Log levels.

DEBUG < INFO < WARNING < ERROR < DISABLED