USRP Hardware Driver and USRP Manual  Version: 003.008.002-0-ge9d11b35
UHD and USRP Manual
log.hpp File Reference
#include <uhd/config.hpp>
#include <uhd/utils/pimpl.hpp>
#include <boost/current_function.hpp>
#include <boost/format.hpp>
#include <ostream>
#include <string>
#include <sstream>

Go to the source code of this file.

Classes

class  uhd::_log::log
 Internal logging object (called by UHD_LOG macros) More...
 

Namespaces

 uhd
 
 uhd::_log
 

Macros

#define UHD_LOGV(verbosity)   uhd::_log::log(uhd::_log::verbosity, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION)
 
#define UHD_LOG   UHD_LOGV(regularly)
 
#define INSERTION_OVERLOAD(x)
 

Enumerations

enum  uhd::_log::verbosity_t {
  uhd::_log::always = 1, uhd::_log::often = 2, uhd::_log::regularly = 3, uhd::_log::rarely = 4,
  uhd::_log::very_rarely = 5, uhd::_log::never = 6
}
 Verbosity levels for the logger. More...
 

Detailed Description

The UHD logging facility.

The logger enables UHD library code to easily log events into a file. Log entries are time-stamped and stored with file, line, and function. Each call to the UHD_LOG macros is synchronous and thread-safe.

The log file can be found in the path <temp-directory>/uhd.log, where <temp-directory> is the user or system's temporary directory. To override <temp-directory>, set the UHD_TEMP_PATH environment variable.

All log messages with verbosity greater than or equal to the log level (in other words, as often or less often than the current log level) are recorded into the log file. All other messages are sent to null.

The default log level is "never", but can be overridden:

  • at compile time by setting the pre-processor define UHD_LOG_LEVEL.
  • at runtime by setting the environment variable UHD_LOG_LEVEL.

UHD_LOG_LEVEL can be the name of a verbosity enum or integer value:

  • Example pre-processor define: -DUHD_LOG_LEVEL=3
  • Example pre-processor define: -DUHD_LOG_LEVEL=regularly
  • Example environment variable: export UHD_LOG_LEVEL=3
  • Example environment variable: export UHD_LOG_LEVEL=regularly

Macro Definition Documentation

◆ INSERTION_OVERLOAD

#define INSERTION_OVERLOAD (   x)
Value:
log& operator<< (x) \
{ \
if(_log_it) _ss << val; \
return *this; \
}

◆ UHD_LOG

#define UHD_LOG   UHD_LOGV(regularly)

A UHD logger macro with default verbosity. Usage: UHD_LOG << "the log message" << std::endl;

◆ UHD_LOGV

#define UHD_LOGV (   verbosity)    uhd::_log::log(uhd::_log::verbosity, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION)

A UHD logger macro with configurable verbosity. Usage: UHD_LOGV(very_rarely) << "the log message" << std::endl;