From a061c617de11b433b1fae733738a2984c83f00dc Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Thu, 19 Apr 2018 11:50:27 -0700 Subject: log: Add method for local generation of messages in log.cpp --- host/lib/utils/log.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'host') diff --git a/host/lib/utils/log.cpp b/host/lib/utils/log.cpp index 58341b9b6..a29c275a8 100644 --- a/host/lib/utils/log.cpp +++ b/host/lib/utils/log.cpp @@ -204,16 +204,7 @@ public: << "Boost_" << BOOST_VERSION << "; " << "UHD_" << uhd::get_version_string(); - auto sys_info_log_msg = uhd::log::logging_info( - pt::microsec_clock::local_time(), - uhd::log::info, - __FILE__, - __LINE__, - "UHD", - boost::this_thread::get_id() - ); - sys_info_log_msg.message = sys_info.str(); - _log_queue.push_with_timed_wait(sys_info_log_msg, 0.25); + _publish_log_msg(sys_info.str(), uhd::log::info, "UHD"); } // Launch log message consumer @@ -421,6 +412,23 @@ private: } } + void _publish_log_msg( + const std::string& msg, + const uhd::log::severity_level level=uhd::log::info, + const std::string& component="LOGGING" + ) { + auto log_msg = uhd::log::logging_info( + pt::microsec_clock::local_time(), + level, + __FILE__, + __LINE__, + component, + boost::this_thread::get_id() + ); + log_msg.message = msg; + _log_queue.push_with_timed_wait(log_msg, 0.25); + } + std::mutex _logmap_mutex; std::atomic _exit; using level_logfn_pair = -- cgit v1.2.3