From 412987430c98e78ccda033ab1cf7a176a4c0b835 Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Thu, 3 May 2018 10:14:01 +1000 Subject: [PATCH] Replace OpenDebugLog() with StartLogging() StartLogging() is used to mark the start of logging generically, whether using -printtoconsole or -debuglogfile. --- src/init.cpp | 4 ++-- src/logging.cpp | 3 ++- src/logging.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 2bb270647..fdfde689f 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1249,10 +1249,10 @@ bool AppInitMain(InitInterfaces& interfaces) // and because this needs to happen before any other debug.log printing LogInstance().ShrinkDebugFile(); } - if (!LogInstance().OpenDebugLog()) { + } + if (!LogInstance().StartLogging()) { return InitError(strprintf("Could not open debug log file %s", LogInstance().m_file_path.string())); - } } if (!LogInstance().m_log_timestamps) diff --git a/src/logging.cpp b/src/logging.cpp index 3eda4995d..f9d9d9c56 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -39,9 +39,10 @@ static int FileWriteStr(const std::string &str, FILE *fp) return fwrite(str.data(), 1, str.size(), fp); } -bool BCLog::Logger::OpenDebugLog() +bool BCLog::Logger::StartLogging() { std::lock_guard scoped_lock(m_file_mutex); + if (!m_print_to_file) return true; assert(m_fileout == nullptr); assert(!m_file_path.empty()); diff --git a/src/logging.h b/src/logging.h index e399d4c30..4fa9e0c8a 100644 --- a/src/logging.h +++ b/src/logging.h @@ -93,7 +93,7 @@ namespace BCLog { /** Returns whether logs will be written to any output */ bool Enabled() const { return m_print_to_console || m_print_to_file; } - bool OpenDebugLog(); + bool StartLogging(); void ShrinkDebugFile(); uint32_t GetCategoryMask() const { return m_categories.load(); }