Merge pull request #51 from QuasarApp/production_game

the "Productions" game fixes
This commit is contained in:
Andrei Yankovich 2025-02-19 13:34:40 +01:00 committed by GitHub
commit 5d020006bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 30 additions and 20 deletions

View File

@ -161,7 +161,7 @@ protected:
* @brief defaultSettings This method must be return default map of the settings and them values. If the default value argument in a getValue method will be skipped, then settings model try find a default value in this map.
* @return The default settings map.
* @see ISettings::getValue
* @example example of implementation of this method:
* **example:** example of implementation of this method:
*
* @code{cpp}
*

View File

@ -16,7 +16,8 @@
namespace QuasarAppUtils {
static QFile* _logFile;
Q_GLOBAL_STATIC(QString, _logFile)
static bool _toFile = false;
static VerboseLvl _verboseLevel = Debug;
@ -28,12 +29,9 @@ static VerboseLvl _verboseLevel = Debug;
QALogger::QALogger() {
_logFile = new QFile();
}
QALogger::~QALogger() {
_logFile->close();
delete _logFile;
}
@ -55,18 +53,17 @@ void messageHandler(QtMsgType type, const QMessageLogContext & context, const QS
if (checkLogType(type, _verboseLevel)) {
if (_toFile && _logFile) {
QTextStream stream(_logFile);
stream << qFormatLogMessage(type, context, msg) << Qt::endl;
_logFile->flush();
if (_toFile && _logFile->size()) {
QFile logFile(*_logFile);
if (logFile.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
QTextStream stream(&logFile);
stream << qFormatLogMessage(type, context, msg) << Qt::endl;
}
}
switch (type) {
case QtMsgType::QtFatalMsg: {
Q_ASSERT_X(false, __FUNCTION__ , qFormatLogMessage(type, context, msg).toLatin1().data());
break;
}
case QtMsgType::QtFatalMsg:
case QtMsgType::QtCriticalMsg:
case QtMsgType::QtWarningMsg: {
std::cerr << qFormatLogMessage(type, context, msg).toStdString() << std::endl;
@ -95,7 +92,8 @@ void QALogger::init() {
if (Params::isEndable("fileLog")) {
_toFile = true;
QString path = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
QString filePath = path + "/" + QCoreApplication::applicationName() + ".log";
QString filePath = path + "/" + QCoreApplication::applicationName() +
" " + QDate::currentDate().toString(Qt::DateFormat::ISODate) + ".log";
auto file = Params::getArg("fileLog");
if (file.size()) {
filePath = file;
@ -103,11 +101,7 @@ void QALogger::init() {
QDir().mkpath(path);
_logFile->setFileName(filePath);
if (!_logFile->open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
qFatal() << "Can't open log file";
}
*_logFile = filePath;
}

View File

@ -69,4 +69,13 @@ bool Settings::initService() {
return ISettings::initService(std::make_unique<Settings>());
}
ISettings *Settings::autoInstance() {
if (auto result = instance()) {
return result;
}
Settings::initService();
return ISettings::instance();
}
}

View File

@ -68,6 +68,13 @@ public:
*/
static bool initService();
/**
* @brief deinitService This method destroy default object of the QuasarAppUtils::Settings type.
* @see ISettings::deinitService
*/
static ISettings *autoInstance();
protected:
void syncImplementation() override;