The UHD logging facility

From Ettus Knowledge Base
Revision as of 11:56, 13 May 2021 by MichaelDickens (Talk | contribs) (Initial creation, part 1)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Application Note Information

AN-001 by Michael Dickens


This application note describes the UHD logging facility: compile-time options, runtime options, application usage, default values and how all of these interact.


UHD has 3 primary files associated with logging: log.hpp, log.cpp, and UHDLog.cmake. There are secondary logging files providing an interface to C and Python.


There are 7 logging levels; the name and number can be used interchangeably for any logging variable.

UHD Logging Levels
trace 0
debug 1
info 2
warning 3
error 4
fatal 5
off 6

There are 2 distinct times where logging can be controlled: during compilation per CMake settings, and during runtime via shell environment variables.

CMake Logging Settings

There are 4 CMake variables that control logging: UHD_LOG_MIN_LEVEL, UHD_LOG_CONSOLE_DISABLE, UHD_LOG_FILE_LEVEL, and UHD_LOG_CONSOLE_LEVEL. Each of these variables can be set independently via the CMake commandline or other methods, and override each's default value. The default values for these variables depend on whether the CMAKE_BUILD_TYPE is debug or not, as follows:

UHD CMake Logging Variables and Default Values for different CMAKE_BUILD_TYPE
Variable non-Debug Debug
UHD_LOG_FILE_LEVEL info (2) trace (0)
UHD_LOG_CONSOLE_LEVEL info (2) debug (0)

Runtime Logging Settings