diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2020-07-22 23:27:01 -0400 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2020-11-03 11:39:02 -0500 |
| commit | 9435202034cafb05ffc11aed48ff57536bce73f7 (patch) | |
| tree | 03c6ad6d1125248dc727d7904721883ac06b616e /src/loglist.cpp | |
| parent | f97e40f127441828eb4ffe11841ebf79191ac8a3 (diff) | |
removed flags from SingleInstance because there's only one left
refactoring in main.cpp:
- moved stuff to loglist.cpp and moapplication.cpp
- split main() into a few functions
Diffstat (limited to 'src/loglist.cpp')
| -rw-r--r-- | src/loglist.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/loglist.cpp b/src/loglist.cpp index 7a64ecad..167b61ef 100644 --- a/src/loglist.cpp +++ b/src/loglist.cpp @@ -327,3 +327,29 @@ void initLogging() qInstallMessageHandler(qtLogCallback);
}
+
+bool createAndMakeWritable(const std::wstring &subPath) {
+ QString const dataPath = qApp->property("dataPath").toString();
+ QString fullPath = dataPath + "/" + QString::fromStdWString(subPath);
+
+ if (!QDir(fullPath).exists() && !QDir().mkdir(fullPath)) {
+ QMessageBox::critical(nullptr, QObject::tr("Error"),
+ QObject::tr("Failed to create \"%1\". Your user "
+ "account probably lacks permission.")
+ .arg(fullPath));
+ return false;
+ } else {
+ return true;
+ }
+}
+
+bool setLogDirectory(const QString& dir)
+{
+ const auto logFile = dir + "/logs/mo_interface.log";
+
+ if (!createAndMakeWritable(AppConfig::logPath())) {
+ return false;
+ }
+
+ log::getDefault().setFile(MOBase::log::File::single(logFile.toStdWString()));
+}
|
