oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
Macros
Logging

Compile-time filtered logging macros over the system console. More...

Macros

#define OVE_LOG_LEVEL   OVE_LOG_LEVEL_INF
 Compile-time log level threshold.
 
#define OVE_LOG_ERR(fmt, ...)   _OVE_LOG_OUTPUT("[E] ", fmt, ##__VA_ARGS__)
 Log an error message.
 
#define OVE_LOG_WRN(fmt, ...)   _OVE_LOG_OUTPUT("[W] ", fmt, ##__VA_ARGS__)
 Log a warning message.
 
#define OVE_LOG_INF(fmt, ...)   _OVE_LOG_OUTPUT("[I] ", fmt, ##__VA_ARGS__)
 Log an informational message.
 
#define OVE_LOG_DBG(fmt, ...)   _OVE_LOG_OUTPUT("[D] ", fmt, ##__VA_ARGS__)
 Log a debug message.
 
#define _OVE_LOG_RAW(fmt, ...)
 Internal helper: format and emit a raw (unprefixed) console line.
 
#define OVE_LOG(fmt, ...)   _OVE_LOG_RAW(fmt, ##__VA_ARGS__)
 Emit a raw (unprefixed) log message.
 

Log level constants

Numeric severity levels in ascending verbosity order. Pass one of these as the value of OVE_LOG_LEVEL to control the compile-time filter.

#define OVE_LOG_LEVEL_ERR   0
 Error level — non-recoverable failures.
 
#define OVE_LOG_LEVEL_WRN   1
 Warning level — unexpected but recoverable conditions.
 
#define OVE_LOG_LEVEL_INF   2
 Info level — normal operational milestones (default).
 
#define OVE_LOG_LEVEL_DBG   3
 Debug level — verbose diagnostic output.
 

Detailed Description

Compile-time filtered logging macros over the system console.

Provides four severity levels: error, warning, info, and debug. The active level is controlled at compile time by defining OVE_LOG_LEVEL to one of the OVE_LOG_LEVEL_* constants before including this header; messages at levels above the configured threshold expand to no-ops and generate no code.

Each macro formats a message with snprintf into a 256-byte stack buffer and writes it through ove_console_write. A trailing newline is appended automatically.

Note
Logging output requires CONFIG_OVE_CONSOLE.

Macro Definition Documentation

◆ OVE_LOG_LEVEL

#define OVE_LOG_LEVEL   OVE_LOG_LEVEL_INF

Compile-time log level threshold.

All log macros with a severity numerically greater than this value expand to no-ops. Defaults to OVE_LOG_LEVEL_INF if not defined externally.

◆ OVE_LOG_ERR

#define OVE_LOG_ERR (   fmt,
  ... 
)    _OVE_LOG_OUTPUT("[E] ", fmt, ##__VA_ARGS__)

Log an error message.

Emits a "[E] " prefixed, newline-terminated message via the console. Expands to a no-op when OVE_LOG_LEVEL < OVE_LOG_LEVEL_ERR.

Parameters
[in]fmtprintf-style format string.
[in]...Format arguments.

◆ OVE_LOG_WRN

#define OVE_LOG_WRN (   fmt,
  ... 
)    _OVE_LOG_OUTPUT("[W] ", fmt, ##__VA_ARGS__)

Log a warning message.

Emits a "[W] " prefixed, newline-terminated message via the console. Expands to a no-op when OVE_LOG_LEVEL < OVE_LOG_LEVEL_WRN.

Parameters
[in]fmtprintf-style format string.
[in]...Format arguments.

◆ OVE_LOG_INF

#define OVE_LOG_INF (   fmt,
  ... 
)    _OVE_LOG_OUTPUT("[I] ", fmt, ##__VA_ARGS__)

Log an informational message.

Emits a "[I] " prefixed, newline-terminated message via the console. Expands to a no-op when OVE_LOG_LEVEL < OVE_LOG_LEVEL_INF.

Parameters
[in]fmtprintf-style format string.
[in]...Format arguments.

◆ OVE_LOG_DBG

#define OVE_LOG_DBG (   fmt,
  ... 
)    _OVE_LOG_OUTPUT("[D] ", fmt, ##__VA_ARGS__)

Log a debug message.

Emits a "[D] " prefixed, newline-terminated message via the console. Expands to a no-op when OVE_LOG_LEVEL < OVE_LOG_LEVEL_DBG.

Parameters
[in]fmtprintf-style format string.
[in]...Format arguments.

◆ _OVE_LOG_RAW

#define _OVE_LOG_RAW (   fmt,
  ... 
)
Value:
do { \
char _ove_log_buf[256]; \
int _ove_log_len = snprintf(_ove_log_buf, \
sizeof(_ove_log_buf), fmt, ##__VA_ARGS__); \
if (_ove_log_len > 0) { \
ove_console_write(_ove_log_buf, \
(unsigned int)_ove_log_len); \
} \
} while (0)

Internal helper: format and emit a raw (unprefixed) console line.

Used by framework internals where the caller controls newlines and prefixes. Output is truncated to 256 bytes.

Parameters
[in]fmtprintf-style format string.
[in]...Format arguments.

◆ OVE_LOG

#define OVE_LOG (   fmt,
  ... 
)    _OVE_LOG_RAW(fmt, ##__VA_ARGS__)

Emit a raw (unprefixed) log message.

Writes a formatted string directly to the console without adding any severity prefix or automatic newline. The caller is responsible for including "\\n" in the format string if needed.

Note
This macro exists for backward compatibility. Prefer the typed variants (OVE_LOG_ERR, OVE_LOG_WRN, OVE_LOG_INF, OVE_LOG_DBG) for new code.
Parameters
[in]fmtprintf-style format string.
[in]...Format arguments.