Skip to content

Commit 8c6f3bf

Browse files
committed
logging, refactor: minor encapsulation improvement and use BCLog::NONE instead of 0
* Make the standalone function `LogCategoryToStr()` private inside `logging.cpp` (aka `static`) - it is only used in that file. * Make the method `Logger::GetLogPrefix()` `private` - it is only used within the class. * Use `BCLog::NONE` to initialize `m_categories` instead of `0`. We later check whether it is `BCLog::NONE` (in `Logger::DefaultShrinkDebugFile()`).
1 parent 160706a commit 8c6f3bf

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/logging.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ std::string BCLog::Logger::LogLevelToStr(BCLog::Level level)
248248
assert(false);
249249
}
250250

251-
std::string LogCategoryToStr(BCLog::LogFlags category)
251+
static std::string LogCategoryToStr(BCLog::LogFlags category)
252252
{
253253
if (category == BCLog::ALL) {
254254
return "all";

src/logging.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ namespace BCLog {
119119
std::atomic<Level> m_log_level{DEFAULT_LOG_LEVEL};
120120

121121
/** Log categories bitfield. */
122-
std::atomic<uint32_t> m_categories{0};
122+
std::atomic<uint32_t> m_categories{BCLog::NONE};
123123

124124
void FormatLogStrInPlace(std::string& str, LogFlags category, Level level, std::string_view source_file, int source_line, std::string_view logging_function, std::string_view threadname, SystemClock::time_point now, std::chrono::seconds mocktime) const;
125125

@@ -132,6 +132,8 @@ namespace BCLog {
132132
void LogPrintStr_(std::string_view str, std::string_view logging_function, std::string_view source_file, int source_line, BCLog::LogFlags category, BCLog::Level level)
133133
EXCLUSIVE_LOCKS_REQUIRED(m_cs);
134134

135+
std::string GetLogPrefix(LogFlags category, Level level) const;
136+
135137
public:
136138
bool m_print_to_console = false;
137139
bool m_print_to_file = false;
@@ -145,8 +147,6 @@ namespace BCLog {
145147
fs::path m_file_path;
146148
std::atomic<bool> m_reopen_file{false};
147149

148-
std::string GetLogPrefix(LogFlags category, Level level) const;
149-
150150
/** Send a string to the log output */
151151
void LogPrintStr(std::string_view str, std::string_view logging_function, std::string_view source_file, int source_line, BCLog::LogFlags category, BCLog::Level level)
152152
EXCLUSIVE_LOCKS_REQUIRED(!m_cs);

0 commit comments

Comments
 (0)