aboutsummaryrefslogtreecommitdiff
path: root/launcher/Application.cpp
diff options
context:
space:
mode:
authorRachel Powers <508861+Ryex@users.noreply.github.com>2023-04-03 15:14:24 -0700
committerRachel Powers <508861+Ryex@users.noreply.github.com>2023-05-01 10:48:00 -0700
commit96decbac27b364e0ffdcb20c40b08a79b827be00 (patch)
tree307871eeddc27f48173ac7df55040e7cf96ab5b3 /launcher/Application.cpp
parent0fb6a2836be2fe51e27a47595950923dca329006 (diff)
downloadPrismLauncher-96decbac27b364e0ffdcb20c40b08a79b827be00.tar.gz
PrismLauncher-96decbac27b364e0ffdcb20c40b08a79b827be00.tar.bz2
PrismLauncher-96decbac27b364e0ffdcb20c40b08a79b827be00.zip
feat: default qtlogging.ini file
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
Diffstat (limited to 'launcher/Application.cpp')
-rw-r--r--launcher/Application.cpp52
1 files changed, 38 insertions, 14 deletions
diff --git a/launcher/Application.cpp b/launcher/Application.cpp
index c8855cbc..f7595512 100644
--- a/launcher/Application.cpp
+++ b/launcher/Application.cpp
@@ -287,6 +287,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
if (QFile::exists(FS::PathCombine(m_rootPath, "portable.txt"))) {
dataPath = m_rootPath;
adjustedBy = "Portable data path";
+ m_portable = true;
}
#endif
}
@@ -411,23 +412,46 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
" " "|" " "
"%{if-category}[%{category}]: %{endif}"
"%{message}");
+
+ bool foundLoggingRules = false;
- if(QFile::exists("logging.ini")) {
+ auto logRulesFile = QStringLiteral("qtlogging.ini");
+ auto logRulesPath = FS::PathCombine(dataPath, logRulesFile);
+
+ qDebug() << "Testing" << logRulesPath << "...";
+ foundLoggingRules = QFile::exists(logRulesPath);
+
+ // search the dataPath()
+
+ if(!foundLoggingRules && ! isPortable()) {
+ logRulesPath = QStandardPaths::locate(QStandardPaths::AppDataLocation, logRulesFile);
+ if(!logRulesPath.isEmpty()) {
+ qDebug() << "Found" << logRulesPath << "...";
+ foundLoggingRules = true;
+ }
+ }
+
+ if(!QFile::exists(logRulesPath)) {
+ logRulesPath = FS::PathCombine(m_rootPath, logRulesFile);
+ qDebug() << "Testing" << logRulesPath << "...";
+ foundLoggingRules = QFile::exists(logRulesPath);
+ }
+
+ if(foundLoggingRules) {
// load and set logging rules
- qDebug() << "Loading logging rules from:" << QString("%1/logging.ini").arg(dataPath);
- INIFile loggingRules;
- bool rulesLoaded = loggingRules.loadFile(QString("logging.ini"));
- if (rulesLoaded) {
- QStringList rules;
- qDebug() << "Setting log rules:";
- for (auto it = loggingRules.begin(); it != loggingRules.end(); ++it) {
- auto rule = it.key() + "=" + it.value().toString();
- rules.append(rule);
- qDebug() << " " << rule;
- }
- auto rules_str = rules.join("\n");
- QLoggingCategory::setFilterRules(rules_str);
+ qDebug() << "Loading logging rules from:" << logRulesPath;
+ QSettings loggingRules(logRulesPath, QSettings::IniFormat);
+ loggingRules.beginGroup("Rules");
+ QStringList rule_names = loggingRules.childKeys();
+ QStringList rules;
+ qDebug() << "Setting log rules:";
+ for (auto rule_name : rule_names) {
+ auto rule = QString("%1=%2").arg(rule_name).arg(loggingRules.value(rule_name).toString());
+ rules.append(rule);
+ qDebug() << " " << rule;
}
+ auto rules_str = rules.join("\n");
+ QLoggingCategory::setFilterRules(rules_str);
}
qDebug() << "<> Log initialized.";