Skip to content

Commit f1379ae

Browse files
committed
Simplify BCLog::Level enum class and LogLevelToStr() function
- simplify the BCLog::Level enum class (and future changes to it) by only setting the value of the first enumerator - move the BCLog::Level:None enumerator to the end of the BCLog::Level enum class and LogLevelToStr() member function, as the None enumerator is only used internally, and by being the highest BCLog::Level value it can be used to iterate over the enumerators - replace the unused BCLog::Level:None string "none" with an empty string as the case will never be hit - add documentation
1 parent a5d5569 commit f1379ae

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/logging.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ struct CLogCategoryDesc {
135135
const CLogCategoryDesc LogCategories[] =
136136
{
137137
{BCLog::NONE, "0"},
138-
{BCLog::NONE, "none"},
138+
{BCLog::NONE, ""},
139139
{BCLog::NET, "net"},
140140
{BCLog::TOR, "tor"},
141141
{BCLog::MEMPOOL, "mempool"},
@@ -187,8 +187,6 @@ bool GetLogCategory(BCLog::LogFlags& flag, const std::string& str)
187187
std::string LogLevelToStr(BCLog::Level level)
188188
{
189189
switch (level) {
190-
case BCLog::Level::None:
191-
return "none";
192190
case BCLog::Level::Debug:
193191
return "debug";
194192
case BCLog::Level::Info:
@@ -197,6 +195,8 @@ std::string LogLevelToStr(BCLog::Level level)
197195
return "warning";
198196
case BCLog::Level::Error:
199197
return "error";
198+
case BCLog::Level::None:
199+
return "";
200200
}
201201
assert(false);
202202
}
@@ -206,7 +206,7 @@ std::string LogCategoryToStr(BCLog::LogFlags category)
206206
// Each log category string representation should sync with LogCategories
207207
switch (category) {
208208
case BCLog::LogFlags::NONE:
209-
return "none";
209+
return "";
210210
case BCLog::LogFlags::NET:
211211
return "net";
212212
case BCLog::LogFlags::TOR:

src/logging.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ namespace BCLog {
6868
ALL = ~(uint32_t)0,
6969
};
7070
enum class Level {
71-
Debug = 0,
72-
None = 1,
73-
Info = 2,
74-
Warning = 3,
75-
Error = 4,
71+
Debug = 0, // High-volume or detailed logging for development/debugging
72+
Info, // Default
73+
Warning,
74+
Error,
75+
None, // Internal use only
7676
};
7777

7878
class Logger

0 commit comments

Comments
 (0)