Merge pull request #5580 from nextcloud/bugfix/log-sizes

Enter next log file if the current log file is larger than 512 KB
This commit is contained in:
Claudio Cambra 2023-04-12 10:46:07 +08:00 committed by GitHub
commit 3860a4cc6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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)