Changeset View
Changeset View
Standalone View
Standalone View
src/logging.cpp
Show First 20 Lines • Show All 176 Lines • ▼ Show 20 Lines | if (m_print_to_console) { | ||||
// Buffer if we haven't opened the log yet. | // Buffer if we haven't opened the log yet. | ||||
if (m_fileout == nullptr) { | if (m_fileout == nullptr) { | ||||
m_msgs_before_open.push_back(strTimestamped); | m_msgs_before_open.push_back(strTimestamped); | ||||
} else { | } else { | ||||
// Reopen the log file, if requested. | // Reopen the log file, if requested. | ||||
if (m_reopen_file) { | if (m_reopen_file) { | ||||
m_reopen_file = false; | m_reopen_file = false; | ||||
fs::path pathDebug = GetDebugLogPath(); | fs::path pathDebug = GetDebugLogPath(); | ||||
m_fileout = fsbridge::freopen(pathDebug, "a", m_fileout); | FILE *new_fileout = fsbridge::fopen(pathDebug, "a"); | ||||
if (!m_fileout) { | if (new_fileout) { | ||||
return; | |||||
} | |||||
// unbuffered. | // unbuffered. | ||||
setbuf(m_fileout, nullptr); | setbuf(m_fileout, nullptr); | ||||
fclose(m_fileout); | |||||
m_fileout = new_fileout; | |||||
} | |||||
} | } | ||||
FileWriteStr(strTimestamped, m_fileout); | FileWriteStr(strTimestamped, m_fileout); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
void BCLog::Logger::ShrinkDebugFile() { | void BCLog::Logger::ShrinkDebugFile() { | ||||
// Amount of debug.log to save at end when shrinking (must fit in memory) | // Amount of debug.log to save at end when shrinking (must fit in memory) | ||||
constexpr size_t RECENT_DEBUG_HISTORY_SIZE = 10 * 1000000; | constexpr size_t RECENT_DEBUG_HISTORY_SIZE = 10 * 1000000; | ||||
▲ Show 20 Lines • Show All 64 Lines • Show Last 20 Lines |