logs: implement logs::get_channels()
This commit is contained in:
@@ -202,6 +202,24 @@ namespace logs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> get_channels()
|
||||||
|
{
|
||||||
|
std::vector<std::string> result;
|
||||||
|
|
||||||
|
std::lock_guard lock(g_mutex);
|
||||||
|
|
||||||
|
for (auto&& p : get_logger()->channels)
|
||||||
|
{
|
||||||
|
// Copy names removing duplicates
|
||||||
|
if (result.empty() || result.back() != p.first)
|
||||||
|
{
|
||||||
|
result.push_back(p.first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Must be called in main() to stop accumulating messages in g_messages
|
// Must be called in main() to stop accumulating messages in g_messages
|
||||||
void set_init()
|
void set_init()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -95,6 +95,9 @@ namespace logs
|
|||||||
|
|
||||||
// Log level control: get channel level
|
// Log level control: get channel level
|
||||||
level get_level(const std::string&);
|
level get_level(const std::string&);
|
||||||
|
|
||||||
|
// Get all registered log 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, ##__VA_ARGS__)
|
||||||
|
|||||||
Reference in New Issue
Block a user