From 2597bde4f9df5409371da55beabb0f695b853aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 27 Oct 2016 13:14:51 +0200 Subject: GH-1665 diagnostic build - check if log file has been created and opened --- application/MultiMC.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp index a226f3b7..0911fcc2 100644 --- a/application/MultiMC.cpp +++ b/application/MultiMC.cpp @@ -429,8 +429,11 @@ void appDebugOutput(QtMsgType type, const QMessageLogContext &context, const QSt QString out = format.arg(buf).arg(levels[type]).arg(msg); - MMC->logFile->write(out.toUtf8()); - MMC->logFile->flush(); + if(MMC->logFile && MMC->logFile->isOpen()) + { + MMC->logFile->write(out.toUtf8()); + MMC->logFile->flush(); + } QTextStream(stderr) << out.toLocal8Bit(); fflush(stderr); } @@ -448,6 +451,11 @@ void MultiMC::initLogger() logFile = std::make_shared(logBase.arg(0)); logFile->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate); + if(!logFile || !logFile->isOpen()) + { + QTextStream(stderr) << "Couldn't open log file for writing: " << logBase.arg(0).toLocal8Bit(); + fflush(stderr); + } } void MultiMC::initGlobalSettings(bool test_mode) -- cgit v1.2.3