diff --git a/src/logging.h b/src/logging.h --- a/src/logging.h +++ b/src/logging.h @@ -83,7 +83,7 @@ ~Logger(); /** Send a string to the log output */ - int LogPrintStr(const std::string &str); + void LogPrintStr(const std::string &str); fs::path GetDebugLogPath(); bool OpenDebugLog(); diff --git a/src/logging.cpp b/src/logging.cpp --- a/src/logging.cpp +++ b/src/logging.cpp @@ -164,38 +164,35 @@ return strStamped; } -int BCLog::Logger::LogPrintStr(const std::string &str) { - // Returns total number of characters written. - int ret = 0; - +void BCLog::Logger::LogPrintStr(const std::string &str) { std::string strTimestamped = LogTimestampStr(str); if (m_print_to_console) { // Print to console. - ret = fwrite(strTimestamped.data(), 1, strTimestamped.size(), stdout); + fwrite(strTimestamped.data(), 1, strTimestamped.size(), stdout); fflush(stdout); } else if (m_print_to_file) { std::lock_guard scoped_lock(m_file_mutex); // Buffer if we haven't opened the log yet. if (m_fileout == nullptr) { - ret = strTimestamped.length(); m_msgs_before_open.push_back(strTimestamped); } else { // Reopen the log file, if requested. if (m_reopen_file) { m_reopen_file = false; fs::path pathDebug = GetDebugLogPath(); - if (fsbridge::freopen(pathDebug, "a", m_fileout) != nullptr) { - // unbuffered. - setbuf(m_fileout, nullptr); + m_fileout = fsbridge::freopen(pathDebug, "a", m_fileout); + if (!m_fileout) { + return; } + // unbuffered. + setbuf(m_fileout, nullptr); } - ret = FileWriteStr(strTimestamped, m_fileout); + FileWriteStr(strTimestamped, m_fileout); } } - return ret; } void BCLog::Logger::ShrinkDebugFile() {