bmv2
Designing your own switch target with bmv2
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Classes | Macros
logger.h File Reference

Go to the source code of this file.

Classes

class  bm::Logger
 

Macros

#define BMLOG_DEBUG(...)   bm::Logger::get()->debug(__VA_ARGS__);
 
#define BMLOG_TRACE(...)   bm::Logger::get()->trace(__VA_ARGS__);
 
#define BMLOG_DEBUG_PKT(pkt, s, ...)
 
#define BMLOG_TRACE_PKT(pkt, s, ...)
 
#define BMLOG_TRACE_SI_PKT(pkt, source_info, s, ...)
 

Detailed Description

Provides logging facilities for bmv2 and targets written using bmv2 We currently used the spdlog as the logging backend so this module is just a wrapper around the spdlog framework.

The preferred way to log messages is using the logging macros:

Macro Definition Documentation

◆ BMLOG_DEBUG

#define BMLOG_DEBUG (   ...)    bm::Logger::get()->debug(__VA_ARGS__);

Preferred way (because can be disabled at compile time) to log a debug message. Is enabled by preprocessor BM_LOG_DEBUG_ON.

◆ BMLOG_DEBUG_PKT

#define BMLOG_DEBUG_PKT (   pkt,
  s,
  ... 
)
Value:
BMLOG_DEBUG("[{}] [cxt {}] " s, (pkt).get_unique_id(), \
(pkt).get_context(), ##__VA_ARGS__)

Same as for BMLOG_DEBUG but for messages regarding a specific packet. Will automatically print the packet id and packet context, along with your message.

◆ BMLOG_TRACE

#define BMLOG_TRACE (   ...)    bm::Logger::get()->trace(__VA_ARGS__);

Preferred way (because can be disabled at compile time) to log a trace message. Is enabled by preprocessor BM_LOG_TRACE_ON.

◆ BMLOG_TRACE_PKT

#define BMLOG_TRACE_PKT (   pkt,
  s,
  ... 
)
Value:
BMLOG_TRACE("[{}] [cxt {}] " s, (pkt).get_unique_id(), \
(pkt).get_context(), ##__VA_ARGS__)

Same as for BMLOG_TRACE but for messages regarding a specific packet. Will automatically print the packet id and packet context, along with your message.

◆ BMLOG_TRACE_SI_PKT

#define BMLOG_TRACE_SI_PKT (   pkt,
  source_info,
  s,
  ... 
)
Value:
BMLOG_TRACE("[{}] [cxt {}] {}" s, (pkt).get_unique_id(), \
(pkt).get_context(), \
(source_info == nullptr) ? "" \
: (source_info->to_string() + " "), \
##__VA_ARGS__)

Same as BMLOG_TRACE_PKT except it takes a pointer to a SourceInfo object, and if non-NULL, include its data in the output.

BMLOG_DEBUG
#define BMLOG_DEBUG(...)
Definition: logger.h:118
BMLOG_TRACE
#define BMLOG_TRACE(...)
Definition: logger.h:126