#include <uhd/config.hpp>
#include <boost/current_function.hpp>
#include <boost/thread/thread.hpp>
#include <ostream>
#include <string>
#include <sstream>
#include <iostream>
Go to the source code of this file.
Classes | |
struct | uhd::log::logging_info |
Namespaces | |
uhd | |
uhd::log | |
Macros | |
#define | UHD_LOG_TRACE(component, message) _UHD_LOG_INTERNAL(component, uhd::log::trace) << message; |
#define | UHD_LOG_DEBUG(component, message) _UHD_LOG_INTERNAL(component, uhd::log::debug) << message; |
#define | UHD_LOG_INFO(component, message) _UHD_LOG_INTERNAL(component, uhd::log::info) << message; |
#define | UHD_LOG_WARNING(component, message) _UHD_LOG_INTERNAL(component, uhd::log::warning) << message; |
#define | UHD_LOG_ERROR(component, message) _UHD_LOG_INTERNAL(component, uhd::log::error) << message; |
#define | UHD_LOG_FATAL(component, message) _UHD_LOG_INTERNAL(component, uhd::log::fatal) << message; |
#define | UHD_LOG_FASTPATH(message) uhd::_log::log_fastpath(message); |
Extra-fast logging macro for when speed matters. More... | |
#define | UHD_LOGGER_TRACE(component) _UHD_LOG_INTERNAL(component, uhd::log::trace) |
#define | UHD_LOGGER_DEBUG(component) _UHD_LOG_INTERNAL(component, uhd::log::debug) |
#define | UHD_LOGGER_INFO(component) _UHD_LOG_INTERNAL(component, uhd::log::info) |
#define | UHD_LOGGER_WARNING(component) _UHD_LOG_INTERNAL(component, uhd::log::warning) |
#define | UHD_LOGGER_ERROR(component) _UHD_LOG_INTERNAL(component, uhd::log::error) |
#define | UHD_LOGGER_FATAL(component) _UHD_LOG_INTERNAL(component, uhd::log::fatal) |
#define | UHD_HERE() UHD_LOGGER_DEBUG("DEBUG") << __FILE__ << ":" << __LINE__; |
Helpful debug tool to print site info. More... | |
#define | UHD_VAR(var) UHD_LOGGER_DEBUG("DEBUG") << #var << " = " << var; |
Helpful debug tool to print a variable. More... | |
#define | UHD_HEX(var) UHD_LOGGER_DEBUG("DEBUG") << #var << " = 0x" << std::hex << std::setfill('0') << std::setw(8) << var << std::dec; |
Helpful debug tool to print a variable in hex. More... | |
Enumerations | |
enum | uhd::log::severity_level { uhd::log::trace = 0, uhd::log::debug = 1, uhd::log::info = 2, uhd::log::warning = 3, uhd::log::error = 4, uhd::log::fatal = 5, uhd::log::off = 6 } |
Functions | |
UHD_API void | uhd::log::set_log_level (uhd::log::severity_level level) |
UHD_API void | uhd::log::set_console_level (uhd::log::severity_level level) |
UHD_API void | uhd::log::set_file_level (uhd::log::severity_level level) |
UHD_API void | uhd::log::set_logger_level (const std::string &logger, uhd::log::severity_level level) |
The logger enables UHD library code to easily log events into a file and display messages above a certain level in the terminal. Log entries are time-stamped and stored with file, line, and function. Each call to the UHD_LOG macros is thread-safe. Each thread will aquire the lock for the logger.
Note: More information on the logging subsystem can be found on UHD Logging.
To disable console logging completely at compile time specify -DUHD_LOG_CONSOLE_DISABLE
during configuration with CMake.
By default no file logging will occur. Set a log file path:
-DUHD_LOG_FILE=$file_path
UHD_LOG_FILE
See also Log levels.
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 to std::clog and/or the log file. Log levels can be specified using string or numeric values of uhd::log::severity_level.
The default log level is "info", but can be overridden:
-DUHD_LOG_MIN_LEVEL
.UHD_LOG_LEVEL
.(-D)UHD_LOG_CONSOLE_LEVEL
at run-/compiletime(-D)UHD_LOG_FILE_LEVEL
at run-/compiletimeUHD_LOG_LEVEL can be the name of a verbosity enum or integer value:
-DUHD_LOG_MIN_LEVEL=3
-DUHD_LOG_MIN_LEVEL=info
export UHD_LOG_LEVEL=3
export UHD_LOG_LEVEL=info
The log format for messages going into a log file is CSV. All log messages going into a logfile will contain following fields:
The log format of log messages displayed on the terminal is plain text with space separated tags prepended. For example:
[INFO] [X300] This is a informational log message
The log format for log output on the console by using these preprocessor defines in CMake:
-DUHD_LOG_CONSOLE_TIME
adds a timestamp [2017-01-01 00:00:00.000000]-DUHD_LOG_CONSOLE_THREAD
adds a thread-id [0x001234]
-DUHD_LOG_CONSOLE_SRC
adds a sourcefile and line tag [src_file:line]
#define UHD_HERE | ( | ) | UHD_LOGGER_DEBUG("DEBUG") << __FILE__ << ":" << __LINE__; |
Helpful debug tool to print site info.
#define UHD_HEX | ( | var | ) | UHD_LOGGER_DEBUG("DEBUG") << #var << " = 0x" << std::hex << std::setfill('0') << std::setw(8) << var << std::dec; |
Helpful debug tool to print a variable in hex.
#define UHD_LOG_DEBUG | ( | component, | |
message | |||
) | _UHD_LOG_INTERNAL(component, uhd::log::debug) << message; |
#define UHD_LOG_ERROR | ( | component, | |
message | |||
) | _UHD_LOG_INTERNAL(component, uhd::log::error) << message; |
#define UHD_LOG_FASTPATH | ( | message | ) | uhd::_log::log_fastpath(message); |
Extra-fast logging macro for when speed matters.
#define UHD_LOG_FATAL | ( | component, | |
message | |||
) | _UHD_LOG_INTERNAL(component, uhd::log::fatal) << message; |
#define UHD_LOG_INFO | ( | component, | |
message | |||
) | _UHD_LOG_INTERNAL(component, uhd::log::info) << message; |
#define UHD_LOG_TRACE | ( | component, | |
message | |||
) | _UHD_LOG_INTERNAL(component, uhd::log::trace) << message; |
#define UHD_LOG_WARNING | ( | component, | |
message | |||
) | _UHD_LOG_INTERNAL(component, uhd::log::warning) << message; |
#define UHD_LOGGER_DEBUG | ( | component | ) | _UHD_LOG_INTERNAL(component, uhd::log::debug) |
#define UHD_LOGGER_ERROR | ( | component | ) | _UHD_LOG_INTERNAL(component, uhd::log::error) |
#define UHD_LOGGER_FATAL | ( | component | ) | _UHD_LOG_INTERNAL(component, uhd::log::fatal) |
#define UHD_LOGGER_INFO | ( | component | ) | _UHD_LOG_INTERNAL(component, uhd::log::info) |
#define UHD_LOGGER_TRACE | ( | component | ) | _UHD_LOG_INTERNAL(component, uhd::log::trace) |
#define UHD_LOGGER_WARNING | ( | component | ) | _UHD_LOG_INTERNAL(component, uhd::log::warning) |
#define UHD_VAR | ( | var | ) | UHD_LOGGER_DEBUG("DEBUG") << #var << " = " << var; |
Helpful debug tool to print a variable.