CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
Logging

Write structured log lines to the badge serial console. More...

Macros

#define LOG_LEVEL_ERROR   0
#define LOG_LEVEL_WARN   1
#define LOG_LEVEL_INFO   2
#define LOG_LEVEL_DEBUG   3
#define LOG_LEVEL_VERBOSE   4

Functions

void host_log (uint8_t level, const char *tag, const char *msg)
 Write a single log line at the given level.
void host_log_hex (const char *tag, const char *label, const uint8_t *data, size_t len)
 Write a labelled hex dump of a binary buffer at debug level.

Detailed Description

Write structured log lines to the badge serial console.

Output is routed through the firmware's cdc_log facility so it shows up on the USB-CDC serial monitor. Use these instead of any platform-native logging primitive.

Macro Definition Documentation

◆ LOG_LEVEL_DEBUG

#define LOG_LEVEL_DEBUG   3

Definition at line 61 of file host_api.h.

Referenced by host_log().

◆ LOG_LEVEL_ERROR

#define LOG_LEVEL_ERROR   0

Definition at line 58 of file host_api.h.

Referenced by host_log().

◆ LOG_LEVEL_INFO

#define LOG_LEVEL_INFO   2

Definition at line 60 of file host_api.h.

Referenced by host_log().

◆ LOG_LEVEL_VERBOSE

#define LOG_LEVEL_VERBOSE   4

Definition at line 62 of file host_api.h.

◆ LOG_LEVEL_WARN

#define LOG_LEVEL_WARN   1

Definition at line 59 of file host_api.h.

Referenced by host_log().

Function Documentation

◆ host_log()

void host_log ( uint8_t level,
const char * tag,
const char * msg )

Write a single log line at the given level.

Definition at line 17 of file host_api_log.cpp.

References LOG_D, LOG_E, LOG_I, LOG_LEVEL_DEBUG, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_WARN, LOG_V, and LOG_W.

Referenced by cdc::plugin_manager::w_host_log().

◆ host_log_hex()

void host_log_hex ( const char * tag,
const char * label,
const uint8_t * data,
size_t len )

Write a labelled hex dump of a binary buffer at debug level.

Definition at line 30 of file host_api_log.cpp.

References LOG_I.

Referenced by cdc::plugin_manager::w_host_log_hex().