mirror of
https://github.com/YACReader/yacreader
synced 2025-06-03 17:18:23 -04:00
Extracted default server log settings to Startup, so there is no need to modify QtWebApp base code.
This commit is contained in:
parent
1657111621
commit
770aeb2533
@ -13,7 +13,6 @@
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <stdio.h>
|
||||
#include "yacreader_global.h"
|
||||
|
||||
void FileLogger::refreshSettings()
|
||||
{
|
||||
@ -23,7 +22,7 @@ void FileLogger::refreshSettings()
|
||||
|
||||
// Load new config settings
|
||||
settings->sync();
|
||||
fileName=settings->value("fileName","server_log.log").toString();
|
||||
fileName=settings->value("fileName").toString();
|
||||
// Convert relative fileName to absolute, based on the directory of the config file.
|
||||
#ifdef Q_OS_WIN32
|
||||
if (QDir::isRelativePath(fileName) && settings->format()!=QSettings::NativeFormat)
|
||||
@ -31,14 +30,14 @@ void FileLogger::refreshSettings()
|
||||
if (QDir::isRelativePath(fileName))
|
||||
#endif
|
||||
{
|
||||
QFileInfo configFile(YACReader::getSettingsPath());
|
||||
fileName=QFileInfo(YACReader::getSettingsPath(),fileName).absoluteFilePath();
|
||||
QFileInfo configFile(settings->fileName());
|
||||
fileName=QFileInfo(configFile.absolutePath(),fileName).absoluteFilePath();
|
||||
}
|
||||
maxSize=settings->value("maxSize",1048576).toLongLong();
|
||||
maxBackups=settings->value("maxBackups",1).toInt();
|
||||
maxSize=settings->value("maxSize",0).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();
|
||||
minLevel=static_cast<QtMsgType>(settings->value("minLevel",QtCriticalMsg).toInt());
|
||||
minLevel=static_cast<QtMsgType>(settings->value("minLevel",0).toInt());
|
||||
bufferSize=settings->value("bufferSize",0).toInt();
|
||||
|
||||
// Create new file if the filename has been changed
|
||||
|
@ -35,6 +35,19 @@ void Startup::start() {
|
||||
mainLogSettings->beginGroup("mainLogFile");
|
||||
//QSettings* debugLogSettings=new QSettings(configFileName,QSettings::IniFormat,app);
|
||||
//debugLogSettings->beginGroup("debugLogFile");
|
||||
|
||||
if(mainLogSettings->value("fileName").isNull())
|
||||
mainLogSettings->setValue("fileName", QFileInfo(YACReader::getSettingsPath(), "server_log.log").absoluteFilePath());
|
||||
|
||||
if(mainLogSettings->value("maxSize").isNull())
|
||||
mainLogSettings->setValue("maxSize",1048576);
|
||||
|
||||
if(mainLogSettings->value("maxBackups").isNull())
|
||||
mainLogSettings->setValue("maxBackups",1);
|
||||
|
||||
if(mainLogSettings->value("minLevel").isNull())
|
||||
mainLogSettings->value("minLevel",QtCriticalMsg).toInt();
|
||||
|
||||
Logger* logger=new FileLogger(mainLogSettings,10000,app);
|
||||
logger->installMsgHandler();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user