Skip to content
Nicolas edited this page Jul 20, 2016 · 10 revisions

6LBR uses its own logging system, different than the one used in Contiki. It is inspired by log4cxx.

This logging system can be either be runtime or compile time for more constrained platform.

LOG6LBR_ Macros

Throughout the 6LBR source code, macros are used to log information to the 6LBR log files:

  LOG6LBR_FATAL()
  LOG6LBR_ERROR()
  LOG6LBR_WARN()
  LOG6LBR_INFO() 
  LOG6LBR_DEBUG()
  LOG6LBR_PACKET()
  LOG6LBR_DUMP()
  LOG6LBR_TRACE()

As opposed to the Contiki PRINTF macros, 6LBR’s log system is less optimized for code size than it is for modularity at runtime. By default, all logging information implemented with the above LOG6LBR_ macros are compiled into the 6LBR binary, but their activation is determined at runtime through two parameters passed to 6LBR: LOG_LEVEL and LOG_SERVICES

LOG_LEVEL: is the level of verbosity.

The macros are organized in a hierarchical manner, and the LOG_LEVEL value (multiplied by 10) determines up to which level the macros are activated, the least verbose mode being 0:

  Log6lbr_Level_FATAL = 0,      // Unrecoverable error detected
  Log6lbr_Level_ERROR = 10,     // Error detected and handled by 6LBR
  Log6lbr_Level_WARN = 20,      // Unexpected condition occurred or important information message
  Log6lbr_Level_INFO = 30,      // Runtime information
  Log6lbr_Level_DEBUG = 40,     // Debug information
  Log6lbr_Level_PACKET = 50,    // Trace printed when a packet is sent/received
  Log6lbr_Level_DUMP = 60,      // Actual packet sent/received
  Log6lbr_Level_TRACE = 70      // Debug traces at packet level

The maximum value is 127, which guarantees full verbosity even if more levels are added.
The default value is 30, which is enough information for a production 6LBR. In that mode, most of the useful logging information of the initialization phase is preserved, and the logging goes relatively silent once the system is running and no errors occur.

  Log6lbr_Level_ALL = 127,
  Log6lbr_Level_DEFAULT = Log6lbr_Level_INFO

LOG_SERVICES: is a bitmask specifying which modules should activate logging. The different modules and their respective values in the bitmask are (copied directly from the enum in the source code):

  Log6lbr_Service_GLOBAL    = 0x00000001,
  Log6lbr_Service_ETH_IN    = 0x00000002,
  Log6lbr_Service_ETH_OUT   = 0x00000004,
  Log6lbr_Service_RADIO_IN  = 0x00000008,
  Log6lbr_Service_RADIO_OUT = 0x00000010,
  Log6lbr_Service_TAP_IN    = 0x00000020,
  Log6lbr_Service_TAP_OUT   = 0x00000040,
  Log6lbr_Service_SLIP_IN   = 0x00000080,
  Log6lbr_Service_SLIP_OUT  = 0x00000100,
  Log6lbr_Service_PF_IN     = 0x00000200,
  Log6lbr_Service_PF_OUT    = 0x00000400,
  Log6lbr_Service_SLIP_DBG  = 0x00000800

All the services are logged with 0xFFFFFFFF (-1), which is also the default value:

  Log6lbr_Service_ALL = -1,
  Log6lbr_Service_DEFAULT = Log6lbr_Service_ALL

Log format

6LBR logs have the following format :

TIMESTAMP: LEVEL: MODULE: MESSAGE
  • TIMESTAMP has the following format : YYYY-MM-DD HH:MM:SS.microsec
  • LEVEL is the name of the level of the message
  • MODULE is the name of the module logging the message
  • MESSAGE is the actual message logged

List of modules :

  • 6LBR: Main 6LBR module
  • ECON: Main Econotag Module (Econotag only)
  • NVM: NVM module
  • SCMD: SLIP Radio command handler
  • ETH: Ethernet high-level driver
  • TAP: Ethernet TAP driver (Native only)
  • ENC: ENC28J60 driver (Econotag only)
  • BR-RDC: Slip Radio high level driver (Native only)
  • SLIP: SLIP driver (Native only)
  • PF: Packet filter
  • 6LE: 6LowPAN Ethernet adaptation layer
  • RIO: Route Information module
  • UDPS: UDP demo server

Usage

Compile time / Runtime logging :

  • Compile time logging : set LOG6LBR_STATIC to 1
  • Runtime time logging : set LOG6LBR_STATIC to 0

Printing macros :

  • LOG_6LBR_<level>( message )
  • LOG6LBR_PRINTF( level, service, message )
  • LOG6LBR_APPEND( level, service, message )
  • LOG6LBR_WRITE( level, service, buffer, size )
  • LOG6LBR_<address>( level, address, message )
  • LOG6LBR_<address>_PRINTF( level, address, message )

Module definition :

This define must be set before including “6lbr-log.h”

#define LOG6LBR_MODULE “module-id”

More information

For more details, please refer to:

Clone this wiki locally