Ethos-U Integration for Cortex-M
Ethos-U Driver
Loading...
Searching...
No Matches

Compile-time logging controls and macros from ethosu_log.h. More...

Macros

#define ETHOSU_LOG_ERR   0
 Error severity level.
#define ETHOSU_LOG_WARN   1
 Warning severity level.
#define ETHOSU_LOG_INFO   2
 Informational severity level.
#define ETHOSU_LOG_DEBUG   3
 Debug severity level.
#define ETHOSU_LOG_ENABLE   1
 Master compile-time switch for driver logging.
#define ETHOSU_LOG_SEVERITY   ETHOSU_LOG_WARN
 Most verbose severity compiled into the driver.
#define LOG(f, ...)
 Write an unprefixed message to stdout.
#define LOG_ERR(f, ...)
 Write an error message to stderr.
#define LOG_WARN(f, ...)
 Write a warning message to stdout.
#define LOG_INFO(f, ...)
 Write an informational message to stdout.
#define LOG_DEBUG(f, ...)
 Write a debug message to stdout.

Description

Compile-time logging controls and macros from ethosu_log.h.

The driver uses printf-style macros that write to the C library stdout and stderr streams. Logging is configured at compile time; it does not provide a runtime callback or logging backend. Embedded targets that enable logging must retarget the required streams to an available output.

Use ETHOSU_LOG_ENABLE as the master switch and ETHOSU_LOG_SEVERITY to select the most verbose severity compiled into the driver. Severity filtering does not apply to LOG. See Text logging for user configuration.

Implementation details

The private source/src/ethosu_log.h header implements compile-time, printf-style logging for the driver and device backends. It does not provide a run-time callback or logging backend.

Macro Output
LOG() Unprefixed text on stdout; no newline is appended.
LOG_ERR() Error text on stderr, prefixed with E:, the source file, and the source line.
LOG_WARN() Warning text on stdout, prefixed with W:.
LOG_INFO() Informational text on stdout, prefixed with I:.
LOG_DEBUG() Debug text on stdout, prefixed with D: and the function name.

ETHOSU_LOG_ENABLE defaults to 1 and controls every logging macro. ETHOSU_LOG_SEVERITY defaults to ETHOSU_LOG_WARN and controls the severity-based macros. The unprefixed LOG macro is controlled by ETHOSU_LOG_ENABLE but is not filtered by ETHOSU_LOG_SEVERITY.

The macros write through the C library stdout and stderr streams. An embedded target that enables logging must retarget those streams to an output such as a UART, semihosting, or an ITM channel. Disabling logging avoids pulling formatted I/O into an application that does not require driver output.

For CMake, the corresponding options accept ON or OFF for ETHOSU_LOG_ENABLE and err, warning, info, or debug for ETHOSU_LOG_SEVERITY. For example:

cmake -S source -B build \
-DETHOSU_LOG_ENABLE=ON \
-DETHOSU_LOG_SEVERITY=debug

Other build systems define the equivalent preprocessor values while compiling the driver sources, for example:

ETHOSU_LOG_ENABLE=1
ETHOSU_LOG_SEVERITY=ETHOSU_LOG_INFO

Macro Definition Documentation

◆ ETHOSU_LOG_ERR

#define ETHOSU_LOG_ERR   0

Error severity level.

Select this value for ETHOSU_LOG_SEVERITY to include only LOG_ERR messages. Its numeric value is 0.

◆ ETHOSU_LOG_WARN

#define ETHOSU_LOG_WARN   1

Warning severity level.

Select this value for ETHOSU_LOG_SEVERITY to include error and warning messages. Its numeric value is 1 and it is the default severity.

◆ ETHOSU_LOG_INFO

#define ETHOSU_LOG_INFO   2

Informational severity level.

Select this value for ETHOSU_LOG_SEVERITY to include error, warning, and informational messages. Its numeric value is 2.

◆ ETHOSU_LOG_DEBUG

#define ETHOSU_LOG_DEBUG   3

Debug severity level.

Select this value for ETHOSU_LOG_SEVERITY to include all severity-based messages. Its numeric value is 3.

◆ ETHOSU_LOG_ENABLE

#define ETHOSU_LOG_ENABLE   1

Master compile-time switch for driver logging.

The default value is 1. Set it to 0 to compile out all logging, including LOG. Arguments to disabled logging macros are not evaluated at runtime. The CMake option with the same name accepts ON or OFF.

◆ ETHOSU_LOG_SEVERITY

#define ETHOSU_LOG_SEVERITY   ETHOSU_LOG_WARN

Most verbose severity compiled into the driver.

The default value is ETHOSU_LOG_WARN. Set it to one of ETHOSU_LOG_ERR, ETHOSU_LOG_WARN, ETHOSU_LOG_INFO, or ETHOSU_LOG_DEBUG. The corresponding CMake option accepts err, warning, info, or debug. This setting does not filter LOG.

◆ LOG

#define LOG ( f,
... )
Value:
LOG_COMMON(stdout, f, ##__VA_ARGS__)

Write an unprefixed message to stdout.

The arguments follow fprintf formatting rules. No newline is appended. Output is controlled by ETHOSU_LOG_ENABLE but not by ETHOSU_LOG_SEVERITY.

◆ LOG_ERR

#define LOG_ERR ( f,
... )
Value:
LOG_COMMON(stderr, "E: %s:%d: " f "\n", strrchr("/" __FILE__, '/') + 1, __LINE__, ##__VA_ARGS__)

Write an error message to stderr.

The arguments follow fprintf formatting rules. The macro prefixes the message with E:, the source file name, and the source line, and appends a newline. It is enabled when ETHOSU_LOG_ENABLE is nonzero and ETHOSU_LOG_SEVERITY is at least ETHOSU_LOG_ERR.

◆ LOG_WARN

#define LOG_WARN ( f,
... )
Value:
LOG_COMMON(stdout, "W: " f "\n", ##__VA_ARGS__)

Write a warning message to stdout.

The arguments follow fprintf formatting rules. The macro prefixes the message with W: and appends a newline. It is enabled when ETHOSU_LOG_ENABLE is nonzero and ETHOSU_LOG_SEVERITY is at least ETHOSU_LOG_WARN.

◆ LOG_INFO

#define LOG_INFO ( f,
... )
Value:
LOG_COMMON_NOP(stdout, f, ##__VA_ARGS__)

Write an informational message to stdout.

The arguments follow fprintf formatting rules. The macro prefixes the message with I: and appends a newline. It is enabled when ETHOSU_LOG_ENABLE is nonzero and ETHOSU_LOG_SEVERITY is at least ETHOSU_LOG_INFO.

◆ LOG_DEBUG

#define LOG_DEBUG ( f,
... )
Value:
LOG_COMMON_NOP(stdout, f, ##__VA_ARGS__)

Write a debug message to stdout.

The arguments follow fprintf formatting rules. The macro prefixes the message with D: and the current function name, and appends a newline. It is enabled when ETHOSU_LOG_ENABLE is nonzero and ETHOSU_LOG_SEVERITY is at least ETHOSU_LOG_DEBUG.