UHD’s logging subsystem captures diagnostic messages generated throughout the driver stack — from device initialization and LO locking through streaming and error recovery — and routes them to one or more configurable backends. Every log entry is time-stamped and tagged with the source file, line number, thread ID, and the component that produced it, making it straightforward to trace exactly what the driver is doing and when.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/EttusResearch/uhd/llms.txt
Use this file to discover all available pages before exploring further.
UHD never prints anything to
stdout. All logging output goes to stderr (technically std::clog) via the console backend, or to a log file via the file backend. This means your application’s standard output stream is always free for structured data.include/uhd/utils/log.hpp.
Log Levels
UHD defines six severity levels as numeric constants inuhd::log::severity_level. Higher numbers indicate higher severity. When you configure a log level threshold, all messages at that level and above are passed through.
trace (0)
Extremely verbose. Logs current execution state, local variable values, and control flow. Use only for deep debugging.
debug (1)
Useful for debugging erroneous behaviour, especially when user input is involved. Includes internal state transitions.
info (2)
Normal operational messages intended to be visible to the user. These are infrequent and indicate expected behaviour.
warning (3)
Something may be wrong but operation can continue. Investigate when these appear unexpectedly.
error (4)
Something has gone wrong. Typically accompanied by an exception or early program termination.
fatal (5)
A severe, unrecoverable failure. Immediate attention required.
off (6) that disables a backend entirely.
Filtering example: if the global log level is set to debug (1), messages at trace (0) are suppressed. If it is set to info (2), both trace and debug messages are suppressed — without recompiling.
Three Layers of Filtering
Log levels are evaluated in order from most restrictive to least. A message must pass every layer before it is delivered to any backend.Compile-time minimum (UHD_LOG_MIN_LEVEL)
Set at build time with the CMake flag Accepted values are numeric (
-DUHD_LOG_MIN_LEVEL=<level>. Any message below this level is permanently removed from the binary — the code for those log calls is not emitted at all.0–5) or the level name (trace, debug, info, warning, error, fatal).Global runtime level (UHD_LOG_LEVEL)
Controls the minimum level accepted across all backends at runtime. Raising this above the compile-time minimum narrows what is logged; lowering it below has no effect (compile-time minimum is the floor).Can also be changed programmatically (see Programmatic API below).
Backends
UHD provides two logging backends out of the box. Additional backends can be registered at runtime viauhd::log::add_logger() (declared in include/uhd/utils/log_add.hpp).
Console backend (stderr)
Console backend (stderr)
The console backend writes formatted log messages to Optional prefixes can be enabled at compile time:
Disabling at compile timeConfiguring level at runtime
std::clog (which maps to stderr). It is enabled by default.Log formatEach line is plain text with space-separated tag fields prepended to the message:| CMake flag | Adds to each line |
|---|---|
-DUHD_LOG_CONSOLE_TIME | Timestamp: [2024-01-15 14:32:00.123456] |
-DUHD_LOG_CONSOLE_THREAD | Thread ID: [0x7f3b2c] |
-DUHD_LOG_CONSOLE_SRC | Source location: [x300_impl.cpp:427] |
File backend
File backend
The file backend writes all log messages to a CSV file. Each row contains:At runtime via environment variable (overrides compile-time default):Configuring file log level
- Timestamp
- Thread ID
- Source file and line number
- Severity level
- Component/channel name
- Log message text
Environment Variable Reference
| Variable | Scope | Description |
|---|---|---|
UHD_LOG_LEVEL | Global | Runtime global minimum log level (numeric or name) |
UHD_LOG_CONSOLE_LEVEL | Console backend | Minimum level for console output |
UHD_LOG_FILE_LEVEL | File backend | Minimum level for file output |
UHD_LOG_FILE | File backend | Path to the log file; file logging is off when unset |
Programmatic API
uhd/utils/log.hpp exposes C++ functions to change log levels at runtime without restarting your application.
set_logger_level() throws uhd::key_error if the named logger does not exist. The built-in names are "console" and "file".severity_level enum values and their numeric equivalents:
Logging Macros for Custom UHD Extensions
When writing code that extends UHD (custom RFNoC blocks, custom transports, out-of-tree modules), use the standard UHD logging macros instead ofstd::cerr or printf. This ensures your messages flow through the same filtering and formatting pipeline as the rest of the driver.
Two macro styles are available:
Macro-style (fastest, compile-time removable)
UHD_LOG_MIN_LEVEL). Use them in hot paths where the logging overhead must be zero in production builds.
Stream-style (more flexible, always present in binary)
RFNoC convenience macros
Inside an RFNoC block implementation that has access tothis->get_unique_id(), the RFNOC_LOG_* family automatically fills in the component name:
Macro arguments
EveryUHD_LOG_* and UHD_LOGGER_* macro takes two arguments:
| Argument | Description |
|---|---|
component | A string label identifying the subsystem (e.g. "X300", "MyBlock"). Shown in brackets in the console output: [INFO] [X300] … |
message | The log message. For macro-style, must be a single expression; for stream-style, any sequence of <<-separated values. |
Debugging helpers
log.hpp also defines several one-liner debug helpers:
