mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
fixed the server log behaviour
This commit is contained in:
parent
6bad2870dc
commit
babd1ce966
@ -32,7 +32,7 @@ void FileLogger::refreshSettings() {
|
||||
QFileInfo configFile(settings->fileName());
|
||||
fileName=QFileInfo(configFile.absolutePath(),fileName).absoluteFilePath();
|
||||
}
|
||||
maxSize=settings->value("maxSize",0).toLongLong();
|
||||
maxSize=settings->value("maxSize",128000).toLongLong();
|
||||
maxBackups=settings->value("maxBackups",0).toInt();
|
||||
msgFormat=settings->value("msgFormat","{timestamp} {type} {msg}").toString();
|
||||
timestampFormat=settings->value("timestampFormat","{yyyy-MM-dd hh:mm:ss.zzz}").toString();
|
||||
@ -105,8 +105,8 @@ void FileLogger::open() {
|
||||
qWarning("Name of logFile is empty");
|
||||
}
|
||||
else {
|
||||
file=new QFile(fileName);
|
||||
if (!file->open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
|
||||
file=new QFile(QDir::cleanPath(fileName));
|
||||
if (!file->open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
qWarning("Cannot open log file %s: %s",qPrintable(fileName),qPrintable(file->errorString()));
|
||||
file=0;
|
||||
}
|
||||
@ -147,7 +147,8 @@ void FileLogger::rotate() {
|
||||
}
|
||||
|
||||
// Backup the current logfile
|
||||
QFile::rename(fileName,fileName+".1");
|
||||
if(maxBackups>0)
|
||||
QFile::rename(fileName,fileName+".1");
|
||||
}
|
||||
|
||||
|
||||
@ -166,7 +167,8 @@ void FileLogger::timerEvent(QTimerEvent* event) {
|
||||
|
||||
// Rotate the file if it is too large
|
||||
if (maxSize>0 && file->size()>=maxSize) {
|
||||
close();
|
||||
|
||||
close();
|
||||
rotate();
|
||||
open();
|
||||
}
|
||||
|
0
release/server/logs/log.log
Normal file
0
release/server/logs/log.log
Normal file
Loading…
x
Reference in New Issue
Block a user