diff --git a/Utilities/Log.cpp b/Utilities/Log.cpp index 87b72068a5..37deb3c5bd 100644 --- a/Utilities/Log.cpp +++ b/Utilities/Log.cpp @@ -202,6 +202,24 @@ namespace logs } } + std::vector get_channels() + { + std::vector 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 void set_init() { diff --git a/Utilities/Log.h b/Utilities/Log.h index 1892be4fdb..29ae28667e 100644 --- a/Utilities/Log.h +++ b/Utilities/Log.h @@ -95,6 +95,9 @@ namespace logs // Log level control: get channel level level get_level(const std::string&); + + // Get all registered log channels + std::vector get_channels(); } #define LOG_CHANNEL(ch, ...) inline ::logs::channel ch(#ch, ##__VA_ARGS__)