should help not loosing too much logs in case of a crash or similar not
nominal stop of the client
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
constexpr int CrashLogSize = 20;
constexpr auto MaxLogLinesCount = 50000;
+constexpr auto MaxLogLinesBeforeFlush = 10;
static bool compressLog(const QString &originalName, const QString &targetName)
{
if (_logstream) {
(*_logstream) << msg << "\n";
- if (_doFileFlush)
+ ++_linesCounter;
+ if (_doFileFlush ||
+ _linesCounter >= MaxLogLinesBeforeFlush ||
+ type == QtMsgType::QtWarningMsg || type == QtMsgType::QtCriticalMsg || type == QtMsgType::QtFatalMsg) {
_logstream->flush();
+ _linesCounter = 0;
+ }
}
if (_permanentDeleteLogStream && ctx.category && strcmp(ctx.category, lcPermanentLog().categoryName()) == 0) {
(*_permanentDeleteLogStream) << msg << "\n";
QFile _logFile;
bool _doFileFlush = false;
+ int _linesCounter = 0;
int _logExpire = 0;
bool _logDebug = false;
QScopedPointer<QTextStream> _logstream;