11#include <boost/date_time/posix_time/posix_time_types.hpp>
12#include <boost/optional.hpp>
110namespace uhd {
namespace log {
130 const std::string& log_level_str);
142 const std::string& file_,
143 const unsigned int& line_,
144 const std::string& component_,
145 const std::thread::id& thread_id_)
147 , verbosity(verbosity_)
150 , component(component_)
151 , thread_id(thread_id_)
196#define _UHD_LOG_INTERNAL(component, level) \
197 uhd::_log::log(level, __FILE__, __LINE__, component, std::this_thread::get_id())
201#if UHD_LOG_MIN_LEVEL < 1
202# define UHD_LOG_TRACE(component, message) \
203 _UHD_LOG_INTERNAL(component, uhd::log::trace) << message;
205# define UHD_LOG_TRACE(component, message)
208#if UHD_LOG_MIN_LEVEL < 2
209# define UHD_LOG_DEBUG(component, message) \
210 _UHD_LOG_INTERNAL(component, uhd::log::debug) << message;
212# define UHD_LOG_DEBUG(component, message)
215#if UHD_LOG_MIN_LEVEL < 3
216# define UHD_LOG_INFO(component, message) \
217 _UHD_LOG_INTERNAL(component, uhd::log::info) << message;
219# define UHD_LOG_INFO(component, message)
222#if UHD_LOG_MIN_LEVEL < 4
223# define UHD_LOG_WARNING(component, message) \
224 _UHD_LOG_INTERNAL(component, uhd::log::warning) << message;
226# define UHD_LOG_WARNING(component, message)
229#if UHD_LOG_MIN_LEVEL < 5
230# define UHD_LOG_ERROR(component, message) \
231 _UHD_LOG_INTERNAL(component, uhd::log::error) << message;
233# define UHD_LOG_ERROR(component, message)
236#if UHD_LOG_MIN_LEVEL < 6
237# define UHD_LOG_FATAL(component, message) \
238 _UHD_LOG_INTERNAL(component, uhd::log::fatal) << message;
240# define UHD_LOG_FATAL(component, message)
243#define RFNOC_LOG_TRACE(message) UHD_LOG_TRACE(this->get_unique_id(), message)
244#define RFNOC_LOG_DEBUG(message) UHD_LOG_DEBUG(this->get_unique_id(), message)
245#define RFNOC_LOG_INFO(message) UHD_LOG_INFO(this->get_unique_id(), message)
246#define RFNOC_LOG_WARNING(message) UHD_LOG_WARNING(this->get_unique_id(), message)
247#define RFNOC_LOG_ERROR(message) UHD_LOG_ERROR(this->get_unique_id(), message)
248#define RFNOC_LOG_FATAL(message) UHD_LOG_FATAL(this->get_unique_id(), message)
250#ifndef UHD_LOG_FASTPATH_DISABLE
255# define UHD_LOG_FASTPATH(message) uhd::_log::log_fastpath(message);
257# define UHD_LOG_FASTPATH(message)
261#define UHD_LOGGER_TRACE(component) _UHD_LOG_INTERNAL(component, uhd::log::trace)
262#define UHD_LOGGER_DEBUG(component) _UHD_LOG_INTERNAL(component, uhd::log::debug)
263#define UHD_LOGGER_INFO(component) _UHD_LOG_INTERNAL(component, uhd::log::info)
264#define UHD_LOGGER_WARNING(component) _UHD_LOG_INTERNAL(component, uhd::log::warning)
265#define UHD_LOGGER_ERROR(component) _UHD_LOG_INTERNAL(component, uhd::log::error)
266#define UHD_LOGGER_FATAL(component) _UHD_LOG_INTERNAL(component, uhd::log::fatal)
272 UHD_LOGGER_DEBUG("DEBUG") \
273 << __FILE__ << ":" << __LINE__ << " (" << UHD_PRETTY_FUNCTION << ")";
276# define UHD_HERE() UHD_LOGGER_DEBUG("DEBUG") << __FILE__ << ":" << __LINE__;
280#define UHD_VAR(var) UHD_LOGGER_DEBUG("DEBUG") << #var << " = " << var;
283#define UHD_HEX(var) \
284 UHD_LOGGER_DEBUG("DEBUG") << #var << " = 0x" << std::hex << std::setfill('0') \
285 << std::setw(8) << var << std::dec;
292void UHD_API log_fastpath(
const std::string&);
299 const std::string& file,
300 const unsigned int line,
301 const std::string& component,
302 const std::thread::id thread_id);
308#define INSERTION_OVERLOAD(x) \
318 template <
typename T>
319 INSERTION_OVERLOAD(T val)
322 INSERTION_OVERLOAD(std::ostream& (*val)(std::ostream&))
323 INSERTION_OVERLOAD(std::ios& (*val)(std::ios&))
324 INSERTION_OVERLOAD(std::ios_base& (*val)(std::ios_base&))
327 std::ostringstream _ss;
#define UHD_API
Definition: config.h:87
UHD_API void set_logger_level(const std::string &logger, uhd::log::severity_level level)
UHD_API void set_console_level(uhd::log::severity_level level)
UHD_API void set_log_level(uhd::log::severity_level level)
boost::optional< uhd::log::severity_level > UHD_API parse_log_level_from_string(const std::string &log_level_str)
UHD_API void set_file_level(uhd::log::severity_level level)
severity_level
Definition: log.hpp:116
@ warning
Definition: log.hpp:120
@ fatal
Definition: log.hpp:122
@ error
Definition: log.hpp:121
@ trace
Definition: log.hpp:117
@ off
Definition: log.hpp:123
@ info
Definition: log.hpp:119
@ debug
Definition: log.hpp:118
Definition: build_info.hpp:12
std::string file
Definition: log.hpp:157
std::thread::id thread_id
Definition: log.hpp:160
logging_info(const boost::posix_time::ptime &time_, const uhd::log::severity_level &verbosity_, const std::string &file_, const unsigned int &line_, const std::string &component_, const std::thread::id &thread_id_)
Definition: log.hpp:140
logging_info()
Definition: log.hpp:139
std::string component
Definition: log.hpp:159
boost::posix_time::ptime time
Definition: log.hpp:155
unsigned int line
Definition: log.hpp:158
uhd::log::severity_level verbosity
Definition: log.hpp:156
std::string message
Definition: log.hpp:161