diff options
author | mattprost <matt.prost@ni.com> | 2020-04-06 16:24:19 -0500 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2020-04-14 10:30:04 -0500 |
commit | 9d6d26ca350b9cc055a556dd420d56f48384ddf4 (patch) | |
tree | 3c3f3949b1339cd2d88c51a43563614e2997a5c3 /host/lib/utils/log.cpp | |
parent | a80ec7c58a1bacd4c3bbd972b188c2bd55e332ab (diff) | |
download | uhd-9d6d26ca350b9cc055a556dd420d56f48384ddf4.tar.gz uhd-9d6d26ca350b9cc055a556dd420d56f48384ddf4.tar.bz2 uhd-9d6d26ca350b9cc055a556dd420d56f48384ddf4.zip |
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 <matt.prost@ni.com>
Diffstat (limited to 'host/lib/utils/log.cpp')
-rw-r--r-- | host/lib/utils/log.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
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 |