From d5f019c3d3f8e483988f1de4c040a905e706fa7c Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Fri, 31 Jan 2020 15:18:25 +0300 Subject: [PATCH] Implement logs::silence Disables all log channels. Also disables unsupported "default" log level for log channels. --- Utilities/Log.cpp | 10 ++++++++++ Utilities/Log.h | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Utilities/Log.cpp b/Utilities/Log.cpp index 37deb3c5bd..0d2f21ca5a 100644 --- a/Utilities/Log.cpp +++ b/Utilities/Log.cpp @@ -173,6 +173,16 @@ namespace logs } } + void silence() + { + std::lock_guard lock(g_mutex); + + for (auto&& pair : get_logger()->channels) + { + pair.second->enabled = level::always; + } + } + void set_level(const std::string& ch_name, level value) { std::lock_guard lock(g_mutex); diff --git a/Utilities/Log.h b/Utilities/Log.h index 29ae28667e..a3a38a352a 100644 --- a/Utilities/Log.h +++ b/Utilities/Log.h @@ -90,6 +90,9 @@ namespace logs // Log level control: set all channels to level::notice void reset(); + // Log level control: set all channels to level::always + void silence(); + // Log level control: register channel if necessary, set channel level void set_level(const std::string&, level); @@ -100,7 +103,7 @@ namespace logs std::vector get_channels(); } -#define LOG_CHANNEL(ch, ...) inline ::logs::channel ch(#ch, ##__VA_ARGS__) +#define LOG_CHANNEL(ch) inline ::logs::channel ch(#ch) // Legacy: