GPS Device
Loading...
Searching...
No Matches
log.h File Reference

Log subsystem public API. More...

#include "stm32f401re.h"
#include "stm32f401re_usart.h"
#include "stm32f401re_gpio.h"
#include "err.h"
#include "configuration.h"
#include "modules.h"
Include dependency graph for log.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  LOG_HANDLE_ts
 Configuration handle for initializing the log subsystem. More...

Macros

#define LOG_INFO(subsys, lvl, fmt, ...)
#define LOG_DEBUG(subsys, lvl, fmt, ...)
#define LOG_WARNING(subsys, lvl, fmt, ...)
#define LOG_ERROR(subsys, lvl, fmt, ...)
#define LOG_CRITICAL(subsys, lvl, fmt, ...)

Enumerations

enum  LOG_LEVEL_te {
  LOG_LEVEL_INFO , LOG_LEVEL_DEBUG , LOG_LEVEL_WARNING , LOG_LEVEL_ERROR ,
  LOG_LEVEL_CRITICAL , LOG_LEVEL_NONE , LOG_LEVEL_COUNT
}
 Log severity levels, in ascending order of severity. More...

Functions

ERR_te log_init (LOG_HANDLE_ts *log_handle)
 Initializes the log subsystem.
ERR_te log_deinit (void)
 Deinitializes the log subsystem.
ERR_te log_print (MODULES_te subsys, LOG_LEVEL_te subsys_log_level, LOG_LEVEL_te log_level, char *msg,...)
 Prints a formatted message to the serial terminal if the severity threshold is met.
ERR_te log_get_level_name (LOG_LEVEL_te log_level, char *str)
 Converts a LOG_LEVEL_te value to its lowercase string name.
ERR_te log_level_to_int (char const *str, LOG_LEVEL_te *log_level_o)
 Converts a log level name string to its LOG_LEVEL_te value.
ERR_te log_set_force_disable (bool bool_status)
 Enables or disables forced suppression of all log output.

Detailed Description

Log subsystem public API.

Author
github.com/Baksi675

This module provides serial logging over USART with per-message severity levels and per-subsystem log level filtering. Each log message is prefixed with an RTC timestamp, the severity level, and the originating subsystem name.

Logging is controlled at two levels:

  • Compile time: define CONFIG_COMPILE_WITH_LOGGING to enable the LOG_INFO, LOG_DEBUG, LOG_WARNING, LOG_ERROR, and LOG_CRITICAL macros. Without this define, all macros expand to no-ops and the logging overhead is eliminated entirely.
  • Runtime: each subsystem holds a LOG_LEVEL_te variable. A message is only printed if its severity is greater than or equal to the subsystem's current level. The level can be adjusted at runtime via the CLI.

Typical usage:

Version
0.1
Date
2026-01-23

Definition in file log.h.