From 5e98855847590cfff4e04aa7c3d593f0d30e7202 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Fri, 2 Aug 2019 07:01:06 -0400 Subject: create log directory sooner to handle creating new instances reset the log file in case MO is restarted and the previously selected instance is deleted switched back to single `mo_interface.log` file --- src/main.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 0e61a781..911f11c3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -120,10 +120,6 @@ bool bootstrap() removeOldFiles(qApp->property("dataPath").toString() + "/" + QString::fromStdWString(AppConfig::logPath()), "usvfs*.log", 5, QDir::Name); - if (!createAndMakeWritable(AppConfig::logPath())) { - return false; - } - return true; } @@ -906,6 +902,10 @@ int main(int argc, char *argv[]) } // we continue for the primary instance OR if MO was called with parameters do { + // make sure the log file isn't locked in case MO was restarted and + // the previous instance gets deleted + log::getDefault().setFile({}); + QString dataPath; try { @@ -926,8 +926,12 @@ int main(int argc, char *argv[]) const auto logFile = qApp->property("dataPath").toString() + "/logs/mo_interface.log"; - log::getDefault().setFile(MOBase::log::File::rotating( - logFile.toStdWString(), 5*1024*1024, 5)); + if (!createAndMakeWritable(AppConfig::logPath())) { + reportError("Failed to create log folder"); + return 1; + } + + log::getDefault().setFile(MOBase::log::File::single(logFile.toStdWString())); QString splash = dataPath + "/splash.png"; if (!QFile::exists(dataPath + "/splash.png")) { -- cgit v1.3.1