Skip to content

These module docs are in beta and may be incomplete.

modm:debug: Logging

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:

  • MODM_LOG_DEBUG
  • MODM_LOG_INFO
  • MODM_LOG_WARNING
  • MODM_LOG_ERROR

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] << ", ";
}
MODM_LOG_DEBUG << modm::flush;

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)
    modm::log::debug
  • modm::log::debug is an instance of modm::Logger: Call of modm::Logger::operator << (T) (with T = int32_t) which is inline
  • IOStream::operator << (T) (with T = int32_t) is inline
  • IOStream::writeInteger(int32_t)
  • IOStream::writeInteger(int32_t) will create the formatted string
  • virtual call of IODevice::write(const char*)
  • redirect to std::cout

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

Content

// Class
class modm::ErrorReport;
class modm::log::DefaultStyle;
class modm::log::Logger;
class modm::log::Prefix< typename T , typename STYLE =DefaultStyle >;
class modm::log::StdColour< Colour TEXT, Colour BACKGROUND, typename STYLE =DefaultStyle >;
class modm::log::Style< typename STYLE =DefaultStyle >;
class modm::log::StyleWrapper< typename STYLE >;
// Enum
enum Colour;
enum Level;
// Variable
Logger modm::log::debug ;
Logger modm::log::error ;
Logger modm::log::info ;
Logger modm::log::warning ;
// Define
#define FILENAME
#define MODM_FILE_INFO
#define MODM_LOG_DEBUG
#define MODM_LOG_ERROR
#define MODM_LOG_INFO
#define MODM_LOG_LEVEL
#define MODM_LOG_OFF
#define MODM_LOG_WARNING

Dependencies

modm:debug modm_debug modm: debug modm_architecture modm: architecture modm_debug->modm_architecture modm_io modm: io modm_debug->modm_io modm_utils modm: utils modm_debug->modm_utils modm_board_disco_f469ni modm: board: disco-f469ni modm_board_disco_f469ni->modm_debug modm_communication_sab modm: communication: sab modm_communication_sab->modm_debug modm_communication_sab2 modm: communication: sab2 modm_communication_sab2->modm_debug modm_communication_xpcc modm: communication: xpcc modm_communication_xpcc->modm_debug modm_driver_adns9800 modm: driver: adns9800 modm_driver_adns9800->modm_debug modm_driver_bme280 modm: driver: bme280 modm_driver_bme280->modm_debug modm_driver_bmp085 modm: driver: bmp085 modm_driver_bmp085->modm_debug modm_driver_mcp2515 modm: driver: mcp2515 modm_driver_mcp2515->modm_debug modm_driver_nrf24 modm: driver: nrf24 modm_driver_nrf24->modm_debug modm_driver_pat9125el modm: driver: pat9125el modm_driver_pat9125el->modm_debug modm_driver_vl53l0 modm: driver: vl53l0 modm_driver_vl53l0->modm_debug modm_driver_vl6180 modm: driver: vl6180 modm_driver_vl6180->modm_debug modm_platform_can modm: platform: can modm_platform_can->modm_debug modm_ui_gui modm: ui: gui modm_ui_gui->modm_debug