mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
log: sort LogCategoriesList and LogCategoriesString alphabetically
This commit is contained in:
@@ -8,6 +8,8 @@
|
|||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
#include <util/time.h>
|
#include <util/time.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
const char * const DEFAULT_DEBUGLOGFILE = "debug.log";
|
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
|
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;
|
std::vector<LogCategory> ret;
|
||||||
for (const CLogCategoryDesc& category_desc : LogCategories) {
|
for (const CLogCategoryDesc& category_desc : categories) {
|
||||||
// Omit the special cases.
|
// Omit the special cases.
|
||||||
if (category_desc.flag != BCLog::NONE && category_desc.flag != BCLog::ALL) {
|
if (category_desc.flag != BCLog::NONE && category_desc.flag != BCLog::ALL) {
|
||||||
LogCategory catActive;
|
LogCategory catActive;
|
||||||
|
|||||||
@@ -138,9 +138,9 @@ namespace BCLog {
|
|||||||
bool DisableCategory(const std::string& str);
|
bool DisableCategory(const std::string& str);
|
||||||
|
|
||||||
bool WillLogCategory(LogFlags category) const;
|
bool WillLogCategory(LogFlags category) const;
|
||||||
/** Returns a vector of the log categories */
|
/** Returns a vector of the log categories in alphabetical order. */
|
||||||
std::vector<LogCategory> LogCategoriesList() const;
|
std::vector<LogCategory> LogCategoriesList() const;
|
||||||
/** Returns a string with the log categories */
|
/** Returns a string with the log categories in alphabetical order. */
|
||||||
std::string LogCategoriesString() const
|
std::string LogCategoriesString() const
|
||||||
{
|
{
|
||||||
return Join(LogCategoriesList(), ", ", [&](const LogCategory& i) { return i.category; });
|
return Join(LogCategoriesList(), ", ", [&](const LogCategory& i) { return i.category; });
|
||||||
|
|||||||
Reference in New Issue
Block a user