Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flush logs every 5 lines written #7495

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/libsync/logger.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/libsync/logger.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/libsync/logger.cpp

File src/libsync/logger.cpp does not conform to Custom style guidelines. (lines 150, 151, 152)
* Copyright (C) by Klaas Freitag <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -37,6 +37,7 @@

constexpr int CrashLogSize = 20;
constexpr auto MaxLogLinesCount = 50000;
constexpr auto MaxLogLinesBeforeFlush = 10;

static bool compressLog(const QString &originalName, const QString &targetName)
{
Expand Down Expand Up @@ -145,8 +146,13 @@

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";
Expand Down
1 change: 1 addition & 0 deletions src/libsync/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#ifndef LOGGER_H
#define LOGGER_H

#include <QObject>

Check failure on line 18 in src/libsync/logger.h

View workflow job for this annotation

GitHub Actions / build

src/libsync/logger.h:18:10 [clang-diagnostic-error]

'QObject' file not found
#include <QList>
#include <QDateTime>
#include <QFile>
Expand Down Expand Up @@ -110,6 +110,7 @@

QFile _logFile;
bool _doFileFlush = false;
int _linesCounter = 0;
int _logExpire = 0;
bool _logDebug = false;
QScopedPointer<QTextStream> _logstream;
Expand Down
Loading