From e7b24461ec650320e2358799764aaba3e1b2e50f Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Fri, 31 Jan 2020 12:09:34 +0300 Subject: [PATCH] Implement logs::get_level --- Utilities/Log.cpp | 16 ++++++++++++++++ Utilities/Log.h | 3 +++ 2 files changed, 19 insertions(+) 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__)