Enter next log file if the current log file is larger than 512 KB when writing log line

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-04-06 21:18:10 +08:00 committed by Matthieu Gallien
parent e0a577172b
commit eed5ca17bd

View File

@ -35,6 +35,7 @@
namespace {
constexpr int CrashLogSize = 20;
constexpr int MaxLogSizeBytes = 1024 * 512;
}
namespace OCC {
@ -117,9 +118,14 @@ void Logger::doLog(QtMsgType type, const QMessageLogContext &ctx, const QString
cout << msg << endl;
#endif
{
if (_logFile.size() >= MaxLogSizeBytes) {
enterNextLogFile();
}
QMutexLocker lock(&_mutex);
_crashLogIndex = (_crashLogIndex + 1) % CrashLogSize;
_crashLog[_crashLogIndex] = msg;
if (_logstream) {
(*_logstream) << msg << Qt::endl;
if (_doFileFlush)