Implement logs::silence
Disables all log channels. Also disables unsupported "default" log level for log channels.
This commit is contained in:
@@ -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)
|
void set_level(const std::string& ch_name, level value)
|
||||||
{
|
{
|
||||||
std::lock_guard lock(g_mutex);
|
std::lock_guard lock(g_mutex);
|
||||||
|
|||||||
+4
-1
@@ -90,6 +90,9 @@ namespace logs
|
|||||||
// Log level control: set all channels to level::notice
|
// Log level control: set all channels to level::notice
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
// Log level control: set all channels to level::always
|
||||||
|
void silence();
|
||||||
|
|
||||||
// Log level control: register channel if necessary, set channel level
|
// Log level control: register channel if necessary, set channel level
|
||||||
void set_level(const std::string&, level);
|
void set_level(const std::string&, level);
|
||||||
|
|
||||||
@@ -100,7 +103,7 @@ namespace logs
|
|||||||
std::vector<std::string> get_channels();
|
std::vector<std::string> get_channels();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LOG_CHANNEL(ch, ...) inline ::logs::channel ch(#ch, ##__VA_ARGS__)
|
#define LOG_CHANNEL(ch) inline ::logs::channel ch(#ch)
|
||||||
|
|
||||||
// Legacy:
|
// Legacy:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user