USRP Hardware Driver and USRP Manual  Version:
UHD and USRP Manual
uhd::log Namespace Reference


struct  logging_info


typedef std::function< void(const uhd::log::logging_info &)> log_fn_t


enum  severity_level {
  trace = 0, debug = 1, info = 2, warning = 3,
  error = 4, fatal = 5, off = 6


boost::optional< uhd::log::severity_level > UHD_API parse_log_level_from_string (const std::string &log_level_str)
UHD_API void set_log_level (uhd::log::severity_level level)
UHD_API void set_console_level (uhd::log::severity_level level)
UHD_API void set_file_level (uhd::log::severity_level level)
UHD_API void set_logger_level (const std::string &logger, uhd::log::severity_level level)
UHD_API void add_logger (const std::string &key, log_fn_t logger_fn)

Typedef Documentation

◆ log_fn_t

typedef std::function<void(const uhd::log::logging_info&)> uhd::log::log_fn_t

Logging function type

Every logging_backend has to define a function with this signature. Can be added to the logging core.

Enumeration Type Documentation

◆ severity_level

Logging severity levels

Either numeric value or string can be used to define loglevel in CMake and environment variables


displays every available log message


displays most log messages necessary for debugging internals


informational messages about setup and what is going on


something is not right but operation can continue


something has gone wrong


something has gone horribly wrong


logging is turned off

Function Documentation

◆ add_logger()

UHD_API void uhd::log::add_logger ( const std::string &  key,
log_fn_t  logger_fn 

Add logging backend to the log system

keyIdentifies the logging backend in the logging core
logger_fnfunction which actually logs messages to this backend

◆ parse_log_level_from_string()

boost::optional<uhd::log::severity_level> UHD_API uhd::log::parse_log_level_from_string ( const std::string &  log_level_str)

Parses a severity_level from a string. If a value could not be parsed, returns none.

◆ set_console_level()

UHD_API void uhd::log::set_console_level ( uhd::log::severity_level  level)

Set the log level for the console logger (if defined).

Short-hand for set_logger_level("console", level);

◆ set_file_level()

UHD_API void uhd::log::set_file_level ( uhd::log::severity_level  level)

Set the log level for the file logger (if defined)

Short-hand for set_logger_level("file", level);

◆ set_log_level()

UHD_API void uhd::log::set_log_level ( uhd::log::severity_level  level)

Set the global log level

The global log level gets applied before the specific log level. So, if the global log level is 'info', no logger can can print messages at level 'debug' or below.

◆ set_logger_level()

UHD_API void uhd::log::set_logger_level ( const std::string &  logger,
uhd::log::severity_level  level 

Set the log level for any specific logger.

loggerName of the logger
levelNew log level for this logger.
uhd::key_errorif logger was not defined