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()`).
pull/29798/head
Vasil Dimov 7 months ago
parent 160706aa38
commit 8c6f3bf163
No known key found for this signature in database
GPG Key ID: 54DF06F64B55CBBF

@ -248,7 +248,7 @@ std::string BCLog::Logger::LogLevelToStr(BCLog::Level level)
assert(false);
}
std::string LogCategoryToStr(BCLog::LogFlags category)
static std::string LogCategoryToStr(BCLog::LogFlags category)
{
if (category == BCLog::ALL) {
return "all";

@ -119,7 +119,7 @@ namespace BCLog {
std::atomic<Level> m_log_level{DEFAULT_LOG_LEVEL};
/** Log categories bitfield. */
std::atomic<uint32_t> m_categories{0};
std::atomic<uint32_t> m_categories{BCLog::NONE};
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;
@ -132,6 +132,8 @@ namespace BCLog {
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)
EXCLUSIVE_LOCKS_REQUIRED(m_cs);
std::string GetLogPrefix(LogFlags category, Level level) const;
public:
bool m_print_to_console = false;
bool m_print_to_file = false;
@ -145,8 +147,6 @@ namespace BCLog {
fs::path m_file_path;
std::atomic<bool> m_reopen_file{false};
std::string GetLogPrefix(LogFlags category, Level level) const;
/** Send a string to the log output */
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)
EXCLUSIVE_LOCKS_REQUIRED(!m_cs);

Loading…
Cancel
Save