Implement logs::get_level

This commit is contained in:
Nekotekina 2020-01-31 12:09:34 +03:00
parent 007a7a5859
commit e7b24461ec
2 changed files with 19 additions and 0 deletions

View File

@ -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()
{

View File

@ -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__)