8 #ifndef INCLUDED_UHD_UTILS_LOG_HPP 9 #define INCLUDED_UHD_UTILS_LOG_HPP 12 #include <boost/current_function.hpp> 13 #include <boost/thread/thread.hpp> 98 namespace uhd {
namespace log {
124 const std::string& file_,
125 const unsigned int& line_,
126 const std::string& component_,
127 const boost::thread::id& thread_id_)
129 , verbosity(verbosity_)
132 , component(component_)
133 , thread_id(thread_id_)
178 #define _UHD_LOG_INTERNAL(component, level) \ 179 uhd::_log::log(level, __FILE__, __LINE__, component, boost::this_thread::get_id()) 183 #if UHD_LOG_MIN_LEVEL < 1 184 # define UHD_LOG_TRACE(component, message) \ 185 _UHD_LOG_INTERNAL(component, uhd::log::trace) << message; 187 # define UHD_LOG_TRACE(component, message) 190 #if UHD_LOG_MIN_LEVEL < 2 191 # define UHD_LOG_DEBUG(component, message) \ 192 _UHD_LOG_INTERNAL(component, uhd::log::debug) << message; 194 # define UHD_LOG_DEBUG(component, message) 197 #if UHD_LOG_MIN_LEVEL < 3 198 # define UHD_LOG_INFO(component, message) \ 199 _UHD_LOG_INTERNAL(component, uhd::log::info) << message; 201 # define UHD_LOG_INFO(component, message) 204 #if UHD_LOG_MIN_LEVEL < 4 205 # define UHD_LOG_WARNING(component, message) \ 206 _UHD_LOG_INTERNAL(component, uhd::log::warning) << message; 208 # define UHD_LOG_WARNING(component, message) 211 #if UHD_LOG_MIN_LEVEL < 5 212 # define UHD_LOG_ERROR(component, message) \ 213 _UHD_LOG_INTERNAL(component, uhd::log::error) << message; 215 # define UHD_LOG_ERROR(component, message) 218 #if UHD_LOG_MIN_LEVEL < 6 219 # define UHD_LOG_FATAL(component, message) \ 220 _UHD_LOG_INTERNAL(component, uhd::log::fatal) << message; 222 # define UHD_LOG_FATAL(component, message) 225 #ifndef UHD_LOG_FASTPATH_DISABLE 230 # define UHD_LOG_FASTPATH(message) uhd::_log::log_fastpath(message); 232 # define UHD_LOG_FASTPATH(message) 236 #define UHD_LOGGER_TRACE(component) _UHD_LOG_INTERNAL(component, uhd::log::trace) 237 #define UHD_LOGGER_DEBUG(component) _UHD_LOG_INTERNAL(component, uhd::log::debug) 238 #define UHD_LOGGER_INFO(component) _UHD_LOG_INTERNAL(component, uhd::log::info) 239 #define UHD_LOGGER_WARNING(component) _UHD_LOG_INTERNAL(component, uhd::log::warning) 240 #define UHD_LOGGER_ERROR(component) _UHD_LOG_INTERNAL(component, uhd::log::error) 241 #define UHD_LOGGER_FATAL(component) _UHD_LOG_INTERNAL(component, uhd::log::fatal) 244 #if defined(__GNUG__) 245 # define UHD_HERE() \ 247 UHD_LOGGER_DEBUG("DEBUG") \ 248 << __FILE__ << ":" << __LINE__ << " (" << __PRETTY_FUNCTION__ << ")"; 250 # define UHD_HERE() UHD_LOGGER_DEBUG("DEBUG") << __FILE__ << ":" << __LINE__; 255 #define UHD_VAR(var) UHD_LOGGER_DEBUG("DEBUG") << #var << " = " << var; 258 #define UHD_HEX(var) \ 259 UHD_LOGGER_DEBUG("DEBUG") << #var << " = 0x" << std::hex << std::setfill('0') \ 260 << std::setw(8) << var << std::dec; 267 void UHD_API log_fastpath(
const std::string&);
274 const std::string& file,
275 const unsigned int line,
276 const std::string& component,
277 const boost::thread::id thread_id);
283 #define INSERTION_OVERLOAD(x) \ 293 template <
typename T>
294 INSERTION_OVERLOAD(T val)
297 INSERTION_OVERLOAD(std::ostream& (*val)(std::ostream&))
298 INSERTION_OVERLOAD(std::ios& (*val)(std::ios&))
299 INSERTION_OVERLOAD(std::ios_base& (*val)(std::ios_base&))
302 std::ostringstream _ss;
boost::posix_time::ptime time
Definition: log.hpp:137
std::string file
Definition: log.hpp:139
unsigned int line
Definition: log.hpp:140
logging_info()
Definition: log.hpp:121
severity_level
Definition: log.hpp:104
Definition: build_info.hpp:13
UHD_API void set_file_level(uhd::log::severity_level level)
uhd::log::severity_level verbosity
Definition: log.hpp:138
UHD_API void set_log_level(uhd::log::severity_level level)
UHD_API void set_logger_level(const std::string &logger, uhd::log::severity_level level)
boost::thread::id thread_id
Definition: log.hpp:142
#define UHD_API
Definition: config.h:68
std::string message
Definition: log.hpp:143
UHD_API void set_console_level(uhd::log::severity_level level)
std::string component
Definition: log.hpp:141
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 boost::thread::id &thread_id_)
Definition: log.hpp:122