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> 97 namespace uhd {
namespace log {
123 const std::string& file_,
124 const unsigned int& line_,
125 const std::string& component_,
126 const boost::thread::id& thread_id_)
128 , verbosity(verbosity_)
131 , component(component_)
132 , thread_id(thread_id_)
177 #define _UHD_LOG_INTERNAL(component, level) \ 178 uhd::_log::log(level, __FILE__, __LINE__, component, boost::this_thread::get_id()) 182 #if UHD_LOG_MIN_LEVEL < 1 183 # define UHD_LOG_TRACE(component, message) \ 184 _UHD_LOG_INTERNAL(component, uhd::log::trace) << message; 186 # define UHD_LOG_TRACE(component, message) 189 #if UHD_LOG_MIN_LEVEL < 2 190 # define UHD_LOG_DEBUG(component, message) \ 191 _UHD_LOG_INTERNAL(component, uhd::log::debug) << message; 193 # define UHD_LOG_DEBUG(component, message) 196 #if UHD_LOG_MIN_LEVEL < 3 197 # define UHD_LOG_INFO(component, message) \ 198 _UHD_LOG_INTERNAL(component, uhd::log::info) << message; 200 # define UHD_LOG_INFO(component, message) 203 #if UHD_LOG_MIN_LEVEL < 4 204 # define UHD_LOG_WARNING(component, message) \ 205 _UHD_LOG_INTERNAL(component, uhd::log::warning) << message; 207 # define UHD_LOG_WARNING(component, message) 210 #if UHD_LOG_MIN_LEVEL < 5 211 # define UHD_LOG_ERROR(component, message) \ 212 _UHD_LOG_INTERNAL(component, uhd::log::error) << message; 214 # define UHD_LOG_ERROR(component, message) 217 #if UHD_LOG_MIN_LEVEL < 6 218 # define UHD_LOG_FATAL(component, message) \ 219 _UHD_LOG_INTERNAL(component, uhd::log::fatal) << message; 221 # define UHD_LOG_FATAL(component, message) 224 #ifndef UHD_LOG_FASTPATH_DISABLE 229 # define UHD_LOG_FASTPATH(message) uhd::_log::log_fastpath(message); 231 # define UHD_LOG_FASTPATH(message) 235 #define UHD_LOGGER_TRACE(component) _UHD_LOG_INTERNAL(component, uhd::log::trace) 236 #define UHD_LOGGER_DEBUG(component) _UHD_LOG_INTERNAL(component, uhd::log::debug) 237 #define UHD_LOGGER_INFO(component) _UHD_LOG_INTERNAL(component, uhd::log::info) 238 #define UHD_LOGGER_WARNING(component) _UHD_LOG_INTERNAL(component, uhd::log::warning) 239 #define UHD_LOGGER_ERROR(component) _UHD_LOG_INTERNAL(component, uhd::log::error) 240 #define UHD_LOGGER_FATAL(component) _UHD_LOG_INTERNAL(component, uhd::log::fatal) 243 #if defined(__GNUG__) 244 # define UHD_HERE() \ 246 UHD_LOGGER_DEBUG("DEBUG") \ 247 << __FILE__ << ":" << __LINE__ << " (" << __PRETTY_FUNCTION__ << ")"; 249 # define UHD_HERE() UHD_LOGGER_DEBUG("DEBUG") << __FILE__ << ":" << __LINE__; 254 #define UHD_VAR(var) UHD_LOGGER_DEBUG("DEBUG") << #var << " = " << var; 257 #define UHD_HEX(var) \ 258 UHD_LOGGER_DEBUG("DEBUG") << #var << " = 0x" << std::hex << std::setfill('0') \ 259 << std::setw(8) << var << std::dec; 266 void UHD_API log_fastpath(
const std::string&);
273 const std::string& file,
274 const unsigned int line,
275 const std::string& component,
276 const boost::thread::id thread_id);
282 #define INSERTION_OVERLOAD(x) \ 292 template <
typename T>
293 INSERTION_OVERLOAD(T val)
296 INSERTION_OVERLOAD(std::ostream& (*val)(std::ostream&))
297 INSERTION_OVERLOAD(std::ios& (*val)(std::ios&))
298 INSERTION_OVERLOAD(std::ios_base& (*val)(std::ios_base&))
301 std::ostringstream _ss;
boost::posix_time::ptime time
Definition: log.hpp:136
std::string file
Definition: log.hpp:138
unsigned int line
Definition: log.hpp:139
logging_info()
Definition: log.hpp:120
severity_level
Definition: log.hpp:103
Definition: build_info.hpp:13
UHD_API void set_file_level(uhd::log::severity_level level)
uhd::log::severity_level verbosity
Definition: log.hpp:137
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:141
#define UHD_API
Definition: config.h:68
std::string message
Definition: log.hpp:142
UHD_API void set_console_level(uhd::log::severity_level level)
std::string component
Definition: log.hpp:140
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:121