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());
|
QFileInfo configFile(settings->fileName());
|
||||||
fileName=QFileInfo(configFile.absolutePath(),fileName).absoluteFilePath();
|
fileName=QFileInfo(configFile.absolutePath(),fileName).absoluteFilePath();
|
||||||
}
|
}
|
||||||
maxSize=settings->value("maxSize",0).toLongLong();
|
maxSize=settings->value("maxSize",128000).toLongLong();
|
||||||
maxBackups=settings->value("maxBackups",0).toInt();
|
maxBackups=settings->value("maxBackups",0).toInt();
|
||||||
msgFormat=settings->value("msgFormat","{timestamp} {type} {msg}").toString();
|
msgFormat=settings->value("msgFormat","{timestamp} {type} {msg}").toString();
|
||||||
timestampFormat=settings->value("timestampFormat","{yyyy-MM-dd hh:mm:ss.zzz}").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");
|
qWarning("Name of logFile is empty");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
file=new QFile(fileName);
|
file=new QFile(QDir::cleanPath(fileName));
|
||||||
if (!file->open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
|
if (!file->open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
qWarning("Cannot open log file %s: %s",qPrintable(fileName),qPrintable(file->errorString()));
|
qWarning("Cannot open log file %s: %s",qPrintable(fileName),qPrintable(file->errorString()));
|
||||||
file=0;
|
file=0;
|
||||||
}
|
}
|
||||||
@ -147,6 +147,7 @@ void FileLogger::rotate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Backup the current logfile
|
// Backup the current logfile
|
||||||
|
if(maxBackups>0)
|
||||||
QFile::rename(fileName,fileName+".1");
|
QFile::rename(fileName,fileName+".1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,6 +167,7 @@ void FileLogger::timerEvent(QTimerEvent* event) {
|
|||||||
|
|
||||||
// Rotate the file if it is too large
|
// Rotate the file if it is too large
|
||||||
if (maxSize>0 && file->size()>=maxSize) {
|
if (maxSize>0 && file->size()>=maxSize) {
|
||||||
|
|
||||||
close();
|
close();
|
||||||
rotate();
|
rotate();
|
||||||
open();
|
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