mirror of
https://github.com/SChernykh/p2pool.git
synced 2025-03-12 09:29:51 +00:00
Log: check for logrotate only once per loop
This commit is contained in:
parent
990916ab62
commit
820c5db5e8
1 changed files with 7 additions and 9 deletions
16
src/log.cpp
16
src/log.cpp
|
@ -194,15 +194,6 @@ private:
|
|||
fwrite(p, 1, size, (severity == 1) ? stdout : stderr);
|
||||
#endif
|
||||
|
||||
// Reopen the log file if it's been moved (logrotate support)
|
||||
if (m_logFile.is_open()) {
|
||||
struct stat buf;
|
||||
if (stat(log_file_name, &buf) != 0) {
|
||||
m_logFile.close();
|
||||
m_logFile.open(log_file_name, std::ios::app | std::ios::binary);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_logFile.is_open()) {
|
||||
if (c) {
|
||||
strip_colors(p, size);
|
||||
|
@ -232,6 +223,13 @@ private:
|
|||
// Flush the log file only after all pending log lines have been written
|
||||
if (m_logFile.is_open()) {
|
||||
m_logFile.flush();
|
||||
|
||||
// Reopen the log file if it's been moved (logrotate support)
|
||||
struct stat buf;
|
||||
if (stat(log_file_name, &buf) != 0) {
|
||||
m_logFile.close();
|
||||
m_logFile.open(log_file_name, std::ios::app | std::ios::binary);
|
||||
}
|
||||
}
|
||||
} while (!stopped);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue