From 9d6d26ca350b9cc055a556dd420d56f48384ddf4 Mon Sep 17 00:00:00 2001 From: mattprost Date: Mon, 6 Apr 2020 16:24:19 -0500 Subject: utils: log: fix logging race condition It was possible that output to cout would become interleaved inside of the uhd log messages. Signed-off-by: mattprost --- host/lib/utils/log.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/host/lib/utils/log.cpp b/host/lib/utils/log.cpp index 4b95c9b8a..fa17d79e8 100644 --- a/host/lib/utils/log.cpp +++ b/host/lib/utils/log.cpp @@ -105,7 +105,8 @@ inline std::string path_to_filename(std::string path) **********************************************************************/ void console_log(const uhd::log::logging_info& log_info) { - std::clog + std::ostringstream log_buffer; + log_buffer #ifdef UHD_LOG_CONSOLE_COLOR << verbosity_color(log_info.verbosity) #endif @@ -124,6 +125,7 @@ void console_log(const uhd::log::logging_info& log_info) << verbosity_color(uhd::log::off) // This will reset colors #endif << log_info.message << std::endl; + std::clog << log_buffer.str(); } /*! Helper class to implement file logging -- cgit v1.2.3