aboutsummaryrefslogtreecommitdiff
path: root/src/logging.cpp
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2021-07-22 16:35:22 +0200
committerJon Atack <jon@atack.com>2021-07-22 23:09:42 +0200
commit7c57297319bc386afaf06528778384fe58576ef9 (patch)
tree9c280d5ef9e282f9577f060b09e61fa46f576b90 /src/logging.cpp
parentf720cfa824f1be863349e7016080f8fb1c3c76c2 (diff)
log: sort LogCategoriesList and LogCategoriesString alphabetically
Diffstat (limited to 'src/logging.cpp')
-rw-r--r--src/logging.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/logging.cpp b/src/logging.cpp
index e5187fd596..fcb46debf7 100644
--- a/src/logging.cpp
+++ b/src/logging.cpp
@@ -8,6 +8,8 @@
#include <util/string.h>
#include <util/time.h>
+#include <algorithm>
+#include <array>
#include <mutex>
const char * const DEFAULT_DEBUGLOGFILE = "debug.log";
@@ -179,8 +181,13 @@ bool GetLogCategory(BCLog::LogFlags& flag, const std::string& str)
std::vector<LogCategory> BCLog::Logger::LogCategoriesList() const
{
+ // Sort log categories by alphabetical order.
+ std::array<CLogCategoryDesc, std::size(LogCategories)> categories;
+ std::copy(std::begin(LogCategories), std::end(LogCategories), categories.begin());
+ std::sort(categories.begin(), categories.end(), [](auto a, auto b) { return a.category < b.category; });
+
std::vector<LogCategory> ret;
- for (const CLogCategoryDesc& category_desc : LogCategories) {
+ for (const CLogCategoryDesc& category_desc : categories) {
// Omit the special cases.
if (category_desc.flag != BCLog::NONE && category_desc.flag != BCLog::ALL) {
LogCategory catActive;