mirror of https://github.com/SChernykh/p2pool
Log: check for logrotate only once per loop
parent
990916ab62
commit
820c5db5e8
16
src/log.cpp
16
src/log.cpp
|
@ -194,15 +194,6 @@ private:
|
||||||
fwrite(p, 1, size, (severity == 1) ? stdout : stderr);
|
fwrite(p, 1, size, (severity == 1) ? stdout : stderr);
|
||||||
#endif
|
#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 (m_logFile.is_open()) {
|
||||||
if (c) {
|
if (c) {
|
||||||
strip_colors(p, size);
|
strip_colors(p, size);
|
||||||
|
@ -232,6 +223,13 @@ private:
|
||||||
// Flush the log file only after all pending log lines have been written
|
// Flush the log file only after all pending log lines have been written
|
||||||
if (m_logFile.is_open()) {
|
if (m_logFile.is_open()) {
|
||||||
m_logFile.flush();
|
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);
|
} while (!stopped);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue