From 4d1afc53be8bc74ce81c7b41d1ba552f2327f88b Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 22 Nov 2019 10:54:47 -0800 Subject: utils: log: Name all threads Logging creates two threads, one for regular logging, and one for fastpath logging. Now these threads are named using uhd::set_thread_name() --- host/lib/utils/log.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'host') diff --git a/host/lib/utils/log.cpp b/host/lib/utils/log.cpp index 64e3e8e44..df18ce97f 100644 --- a/host/lib/utils/log.cpp +++ b/host/lib/utils/log.cpp @@ -11,10 +11,10 @@ #include #include #include +#include #include #include #include -#include #include #include #include @@ -22,8 +22,7 @@ #include #include -namespace pt = boost::posix_time; -constexpr double READ_TIMEOUT = 0.5; // Waiting time to read from the queue +namespace pt = boost::posix_time; // Don't make these static const std::string -- we need their lifetime guaranteed! #define PURPLE "\033[0;35m" // purple @@ -40,6 +39,15 @@ constexpr double READ_TIMEOUT = 0.5; // Waiting time to read from the queue * Helpers **********************************************************************/ namespace { + +#ifdef BOOST_MSVC +constexpr double READ_TIMEOUT = 0.5; // Waiting time to read from the queue +#endif + +constexpr char LOG_THREAD_NAME[] = "uhd_log"; +constexpr char LOG_THREAD_NAME_FP[] = "uhd_log_fastpath"; +constexpr char LOG_THREAD_NAME_FP_DUMMY[] = "uhd_log_fp_dummy"; + std::string verbosity_color(const uhd::log::severity_level& level) { static const bool tty = uhd::is_a_tty(2); // is stderr a tty? @@ -204,14 +212,15 @@ public: { std::ostringstream sys_info; sys_info << BOOST_PLATFORM << "; " << BOOST_COMPILER << "; " - << "Boost_" << BOOST_VERSION << "; " - << uhd::get_component() << "_" << uhd::get_version_string(); + << "Boost_" << BOOST_VERSION << "; " << uhd::get_component() << "_" + << uhd::get_version_string(); _publish_log_msg(sys_info.str(), uhd::log::info, "UHD"); } // Launch log message consumer _pop_task = std::make_shared(std::thread([this]() { this->pop_task(); })); + uhd::set_thread_name(_pop_task.get(), LOG_THREAD_NAME); // Fastpath message consumer #ifndef UHD_LOG_FASTPATH_DISABLE @@ -227,9 +236,11 @@ public: if (enable_fastpath) { _pop_fastpath_task = std::make_shared( std::thread([this]() { this->pop_fastpath_task(); })); + uhd::set_thread_name(_pop_fastpath_task.get(), LOG_THREAD_NAME_FP); } else { _pop_fastpath_task = std::make_shared( std::thread([this]() { this->pop_fastpath_dummy_task(); })); + uhd::set_thread_name(_pop_fastpath_task.get(), LOG_THREAD_NAME_FP_DUMMY); _publish_log_msg("Fastpath logging disabled at runtime."); } #else -- cgit v1.2.3