Skip to content

Logging

Routines to facilitate debugging of Mira. Applications register loggers for different log levels. The loggers decide if they want to log the event and then use a provided va_list of structs to log information about the event.

Note

This API is not guaranteed to be stable across versions.

Types

logger_cb_t

typedef void(* logger_cb_t) (uint32_t event, va_list ap);

Callbacks receiving log events for each log level

The argument list (ap) will contain alterning mira_diag_log_arg_type_t and mira_diag_log_arg_t parameters. The final argument will be LOG_ARG_END. mira_diag_log_arg_type_t will describe the type of the union that follows.

Enums

mira_diag_log_arg_type_t

Possible arguments to log events

Name Description
LOG_ARG_END
LOG_ARG_U8
LOG_ARG_U16
LOG_ARG_U32
LOG_ARG_I8
LOG_ARG_I16
LOG_ARG_I32
LOG_ARG_BOOL
LOG_ARG_STR
LOG_ARG_PTR
LOG_ARG_2BYTE ptr points to a 2-byte buffer
LOG_ARG_5BYTE ptr points to a 5-byte buffer
LOG_ARG_IPV6

Structs

mira_diag_log_arg_t

Each log argument is stored in this struct

Name Type Description
name const char *
u8 uint8_t
u16 uint16_t
u32 uint32_t
i8 int8_t
i16 int16_t
i32 int32_t
b bool
str const char *
ptr const void *
@1 union mira_diag_log_arg_t::@0

mira_diag_log_levels_cb_t

Callbacks receiving loggers for each log level.

Name Type Description
debug logger_cb_t The logger receiviving events on the debug level. It needs to select which events to actually log because of the huge volume.
info logger_cb_t The logger receiving events on the info level. The volume is much lower than on the debug level.
warn logger_cb_t The logger receiving events on the warn level. Handled errors are logged on this level.
fatal logger_cb_t The logger receiving events on the fatal level. Unexpected errors are logged on this level and then the device is restarted.

mira_diag_log_callbacks_t

Name Type Description
is_debug_enabled bool(*)(void) When this callback returns true, power consumption and CPU usage is increased. Some, but not all, debug level logging will be turned off.
is_info_enabled bool(*)(void) When this callback returns true, power consumption and CPU usage is increased. Some, but not all, info level logging will be turned off.
log_quickly void(*)(uint32_t event) This callback is called for some time critical events where the logging routine can not take much time. A typical implementation will see if it is the wanted events and turn on/off a GPIO-pin.
app_log mira_diag_log_levels_cb_t Callbacks for events logged from application context.
irq_log mira_diag_log_levels_cb_t Callbacks for events logged from interrupt context. The routines must be reentrant and fast as different IRQ levels can log through them as well.

Functions

mira_diag_log_set_callbacks

void mira_diag_log_set_callbacks(const mira_diag_log_callbacks_t *cbs);

Register logging callbacks.

Back to top