diff --git a/Utilities/Log.cpp b/Utilities/Log.cpp index 2333b9b410..87b72068a5 100644 --- a/Utilities/Log.cpp +++ b/Utilities/Log.cpp @@ -186,6 +186,22 @@ namespace logs } } + level get_level(const std::string& ch_name) + { + std::lock_guard lock(g_mutex); + + auto found = get_logger()->channels.equal_range(ch_name); + + if (found.first != found.second) + { + return found.first->second->enabled; + } + else + { + return level::always; + } + } + // Must be called in main() to stop accumulating messages in g_messages void set_init() { diff --git a/Utilities/Log.h b/Utilities/Log.h index 9b1ae35606..a9a1b7012f 100644 --- a/Utilities/Log.h +++ b/Utilities/Log.h @@ -92,6 +92,9 @@ namespace logs // Log level control: register channel if necessary, set channel level void set_level(const std::string&, level); + + // Log level control: get channel level + level get_level(const std::string&); } #define LOG_CHANNEL(ch, ...) inline ::logs::channel ch(#ch, ##__VA_ARGS__)