From 107c105e403f4c4cbd2257219c088d62a3875082 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Thu, 20 Apr 2017 13:38:20 -0700 Subject: log: Fix missing add_logger, fix clearing of queue --- host/lib/utils/log.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'host/lib/utils') diff --git a/host/lib/utils/log.cpp b/host/lib/utils/log.cpp index 1d87a0b3d..5d0a9cf5b 100644 --- a/host/lib/utils/log.cpp +++ b/host/lib/utils/log.cpp @@ -221,13 +221,29 @@ public: for (const auto &logger : _loggers) { auto level = logger_level.find(logger.first); if(level != logger_level.end() && log_info.verbosity < level->second){ - UHD_VAR(level->second) - continue; + continue; } logger.second(log_info); } } } + + // Exit procedure: Clear the queue + uhd::log::logging_info log_info; + while (_log_queue.pop_with_haste(log_info)) { + for (const auto &logger : _loggers) { + auto level = logger_level.find(logger.first); + if (level != logger_level.end() && log_info.verbosity < level->second){ + continue; + } + logger.second(log_info); + } + } + } + + void add_logger(const std::string &key, uhd::log::log_fn_t logger_fn) + { + _loggers[key] = logger_fn; } private: @@ -297,6 +313,13 @@ uhd::_log::log::~log(void) } } + +void +uhd::log::add_logger(const std::string &key, log_fn_t logger_fn) +{ + log_rs().add_logger(key, logger_fn); +} + void uhd::log::set_log_level(uhd::log::severity_level level){ log_rs().global_level = level; -- cgit v1.2.3