From cd9d37aac402b0edd0f12b66fd7f2fdd5fe6dff5 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Mon, 2 Feb 2015 02:14:14 +0100 Subject: SCRATCH nuke the overcomplicated logger, use a simple one. --- CMakeLists.txt | 8 -- MMCError.h | 4 +- MultiMC.cpp | 94 ++++++++++------- MultiMC.h | 17 +-- gui/MainWindow.cpp | 10 +- gui/dialogs/AccountSelectDialog.cpp | 4 +- gui/dialogs/UpdateDialog.cpp | 12 +-- gui/dialogs/VersionSelectDialog.cpp | 2 +- gui/groupview/GroupView.cpp | 2 +- gui/groupview/GroupedProxyModel.cpp | 8 +- gui/pages/global/AccountListPage.cpp | 2 +- gui/pages/global/MultiMCPage.cpp | 2 +- logger/QsDebugOutput.cpp | 52 ---------- logger/QsDebugOutput.h | 34 ------ logger/QsLog.cpp | 159 ----------------------------- logger/QsLog.h | 138 ------------------------- logger/QsLogDest.cpp | 104 ------------------- logger/QsLogDest.h | 53 ---------- logic/BaseProcess.cpp | 12 +-- logic/Env.cpp | 8 +- logic/InstanceList.cpp | 32 +++--- logic/JarUtils.cpp | 26 ++--- logic/LegacyInstance.cpp | 2 +- logic/LegacyUpdate.cpp | 2 +- logic/LwjglVersionList.cpp | 12 +-- logic/Mod.cpp | 8 +- logic/ModList.cpp | 18 ++-- logic/OneSixInstance.cpp | 2 +- logic/OneSixUpdate.cpp | 6 +- logic/assets/AssetsUtils.cpp | 22 ++-- logic/auth/MojangAccount.cpp | 8 +- logic/auth/MojangAccountList.cpp | 28 ++--- logic/auth/YggdrasilTask.cpp | 12 +-- logic/auth/flows/AuthenticateTask.cpp | 18 ++-- logic/auth/flows/RefreshTask.cpp | 10 +- logic/auth/flows/ValidateTask.cpp | 2 +- logic/forge/ForgeInstaller.cpp | 8 +- logic/forge/ForgeMirrors.cpp | 6 +- logic/forge/ForgeVersionList.cpp | 12 +-- logic/forge/ForgeXzDownload.cpp | 36 +++---- logic/ftb/FTBProfileStrategy.cpp | 6 +- logic/ftb/OneSixFTBInstance.cpp | 12 +-- logic/icons/IconList.cpp | 12 +-- logic/java/JavaCheckerJob.cpp | 6 +- logic/java/JavaUtils.cpp | 6 +- logic/java/JavaVersionList.cpp | 12 +-- logic/liteloader/LiteLoaderInstaller.cpp | 4 +- logic/liteloader/LiteLoaderVersionList.cpp | 2 +- logic/minecraft/MinecraftProfile.cpp | 2 +- logic/minecraft/MinecraftVersionList.cpp | 34 +++--- logic/minecraft/OneSixProfileStrategy.cpp | 8 +- logic/minecraft/ProfileUtils.cpp | 18 ++-- logic/minecraft/RawLibrary.cpp | 6 +- logic/minecraft/VersionBuilder.cpp | 2 +- logic/minecraft/VersionFile.cpp | 16 +-- logic/net/ByteArrayDownload.cpp | 8 +- logic/net/CacheDownload.cpp | 16 +-- logic/net/HttpMetaCache.cpp | 6 +- logic/net/MD5EtagDownload.cpp | 12 +-- logic/net/NetJob.cpp | 8 +- logic/net/PasteUpload.cpp | 6 +- logic/news/NewsChecker.cpp | 16 +-- logic/screenshots/ImgurAlbumCreation.cpp | 10 +- logic/screenshots/ImgurUpload.cpp | 10 +- logic/settings/SettingsObject.cpp | 8 +- logic/status/StatusChecker.cpp | 14 +-- logic/tasks/Task.cpp | 6 +- logic/trans/TranslationDownloader.cpp | 12 +-- logic/updater/DownloadUpdateTask.cpp | 66 ++++++------ logic/updater/NotificationChecker.cpp | 4 +- tests/tst_DownloadUpdateTask.cpp | 6 +- 71 files changed, 415 insertions(+), 934 deletions(-) delete mode 100644 logger/QsDebugOutput.cpp delete mode 100644 logger/QsDebugOutput.h delete mode 100644 logger/QsLog.cpp delete mode 100644 logger/QsLog.h delete mode 100644 logger/QsLogDest.cpp delete mode 100644 logger/QsLogDest.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 1229bcfa..3751da3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -270,14 +270,6 @@ SET(MULTIMC_SOURCES BuildConfig.h ${PROJECT_BINARY_DIR}/BuildConfig.cpp - # Logging - logger/QsDebugOutput.cpp - logger/QsDebugOutput.h - logger/QsLog.cpp - logger/QsLog.h - logger/QsLogDest.cpp - logger/QsLogDest.h - # GUI - general utilities gui/GuiUtil.h gui/GuiUtil.cpp diff --git a/MMCError.h b/MMCError.h index 1f72b7a4..e81054a6 100644 --- a/MMCError.h +++ b/MMCError.h @@ -1,7 +1,7 @@ #pragma once #include #include -#include +#include class MMCError : public std::exception { @@ -9,7 +9,7 @@ public: MMCError(QString cause) { exceptionCause = cause; - QLOG_ERROR() << "Exception: " + cause; + qCritical() << "Exception: " + cause; }; virtual ~MMCError() noexcept {} virtual const char *what() const noexcept diff --git a/MultiMC.cpp b/MultiMC.cpp index e3319c9a..03131008 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "gui/dialogs/VersionSelectDialog.h" #include "logic/InstanceList.h" @@ -38,8 +39,7 @@ #include #include "logic/settings/INISettingsObject.h" #include "logic/settings/Setting.h" -#include "logger/QsLog.h" -#include "logger/QsLogDest.h" + #include "logic/trans/TranslationDownloader.h" @@ -52,6 +52,8 @@ MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, ar setOrganizationName("MultiMC"); setApplicationName("MultiMC5"); + startTime = QDateTime::currentDateTime(); + setAttribute(Qt::AA_UseHighDpiPixmaps); // Don't quit on hiding the last window this->setQuitOnLastWindowClosed(false); @@ -129,7 +131,7 @@ MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, ar { // BAD STUFF. WHAT DO? initLogger(); - QLOG_ERROR() << "Failed to set work path. Will exit. NOW."; + qCritical() << "Failed to set work path. Will exit. NOW."; m_status = MultiMC::Failed; return; } @@ -166,22 +168,22 @@ MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, ar // init the logger initLogger(); - QLOG_INFO() << "MultiMC 5, (c) 2013-2015 MultiMC Contributors"; - QLOG_INFO() << "Version : " << BuildConfig.VERSION_STR; - QLOG_INFO() << "Git commit : " << BuildConfig.GIT_COMMIT; + qDebug() << "MultiMC 5, (c) 2013-2015 MultiMC Contributors"; + qDebug() << "Version : " << BuildConfig.VERSION_STR; + qDebug() << "Git commit : " << BuildConfig.GIT_COMMIT; if (adjustedBy.size()) { - QLOG_INFO() << "Work dir before adjustment : " << origcwdPath; - QLOG_INFO() << "Work dir after adjustment : " << QDir::currentPath(); - QLOG_INFO() << "Adjusted by : " << adjustedBy; + qDebug() << "Work dir before adjustment : " << origcwdPath; + qDebug() << "Work dir after adjustment : " << QDir::currentPath(); + qDebug() << "Adjusted by : " << adjustedBy; } else { - QLOG_INFO() << "Work dir : " << QDir::currentPath(); + qDebug() << "Work dir : " << QDir::currentPath(); } - QLOG_INFO() << "Binary path : " << binPath; - QLOG_INFO() << "Application root path : " << rootPath; - QLOG_INFO() << "Static data path : " << staticDataPath; + qDebug() << "Binary path : " << binPath; + qDebug() << "Application root path : " << rootPath; + qDebug() << "Static data path : " << staticDataPath; // load settings initGlobalSettings(test_mode); @@ -202,21 +204,21 @@ MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, ar // instance path: check for problems with '!' in instance path and warn the user in the log // and rememer that we have to show him a dialog when the gui starts (if it does so) QString instDir = m_settings->get("InstanceDir").toString(); - QLOG_INFO() << "Instance path : " << instDir; + qDebug() << "Instance path : " << instDir; if (checkProblemticPathJava(QDir(instDir))) { - QLOG_WARN() + qWarning() << "Your instance path contains \'!\' and this is known to cause java problems"; } m_instances.reset(new InstanceList(m_settings, InstDirSetting->get().toString(), this)); - QLOG_INFO() << "Loading Instances..."; + qDebug() << "Loading Instances..."; m_instances->loadList(); connect(InstDirSetting.get(), SIGNAL(SettingChanged(const Setting &, QVariant)), m_instances.get(), SLOT(on_InstFolderChanged(const Setting &, QVariant))); // and accounts m_accounts.reset(new MojangAccountList(this)); - QLOG_INFO() << "Loading accounts..."; + qDebug() << "Loading accounts..."; m_accounts->setListFilePath("accounts.json", true); m_accounts->loadList(); @@ -275,16 +277,16 @@ void MultiMC::initTranslations() { QLocale locale(m_settings->get("Language").toString()); QLocale::setDefault(locale); - QLOG_INFO() << "Your language is" << locale.bcp47Name(); + qDebug() << "Your language is" << locale.bcp47Name(); m_qt_translator.reset(new QTranslator()); if (m_qt_translator->load("qt_" + locale.bcp47Name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath))) { - QLOG_DEBUG() << "Loading Qt Language File for" + qDebug() << "Loading Qt Language File for" << locale.bcp47Name().toLocal8Bit().constData() << "..."; if (!installTranslator(m_qt_translator.get())) { - QLOG_ERROR() << "Loading Qt Language File failed."; + qCritical() << "Loading Qt Language File failed."; m_qt_translator.reset(); } } @@ -296,11 +298,11 @@ void MultiMC::initTranslations() m_mmc_translator.reset(new QTranslator()); if (m_mmc_translator->load("mmc_" + locale.bcp47Name(), staticDataPath + "/translations")) { - QLOG_DEBUG() << "Loading MMC Language File for" + qDebug() << "Loading MMC Language File for" << locale.bcp47Name().toLocal8Bit().constData() << "..."; if (!installTranslator(m_mmc_translator.get())) { - QLOG_ERROR() << "Loading MMC Language File failed."; + qCritical() << "Loading MMC Language File failed."; m_mmc_translator.reset(); } } @@ -327,6 +329,28 @@ void moveFile(const QString &oldName, const QString &newName) QFile::copy(oldName, newName); QFile::remove(oldName); } + + +void appDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) +{ + const char *levels = "DWCF"; + const QString format("%1 %2 %3\n"); + + qint64 msecstotal = MMC->timeSinceStart(); + qint64 seconds = msecstotal / 1000; + qint64 msecs = msecstotal % 1000; + QString foo; + char buf[1025] = {0}; + ::snprintf(buf, 1024, "%5lld.%03lld", seconds, msecs); + + QString out = format.arg(buf).arg(levels[type]).arg(msg); + + MMC->logFile->write(out.toUtf8()); + MMC->logFile->flush(); + QTextStream(stderr) << out.toLocal8Bit(); + fflush(stderr); +} + void MultiMC::initLogger() { static const QString logBase = "MultiMC-%0.log"; @@ -336,15 +360,10 @@ void MultiMC::initLogger() moveFile(logBase.arg(1), logBase.arg(2)); moveFile(logBase.arg(0), logBase.arg(1)); - // init the logging mechanism - QsLogging::Logger &logger = QsLogging::Logger::instance(); - logger.setLoggingLevel(QsLogging::TraceLevel); - m_fileDestination = QsLogging::DestinationFactory::MakeFileDestination(logBase.arg(0)); - m_debugDestination = QsLogging::DestinationFactory::MakeDebugOutputDestination(); - logger.addDestination(m_fileDestination.get()); - logger.addDestination(m_debugDestination.get()); - // log all the things - logger.setLoggingLevel(QsLogging::TraceLevel); + qInstallMessageHandler(appDebugOutput); + + logFile = std::make_shared(logBase.arg(0)); + logFile->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate); } void MultiMC::initGlobalSettings(bool test_mode) @@ -381,7 +400,7 @@ void MultiMC::initGlobalSettings(bool test_mode) QFontInfo consoleFontInfo(consoleFont); QString resolvedDefaultMonospace = consoleFontInfo.family(); QFont resolvedFont(resolvedDefaultMonospace); - QLOG_DEBUG() << "Detected default console font:" << resolvedDefaultMonospace + qDebug() << "Detected default console font:" << resolvedDefaultMonospace << ", substitutions:" << resolvedFont.substitutions().join(','); m_settings->registerSetting("ConsoleFont", resolvedDefaultMonospace); } @@ -527,7 +546,7 @@ void MultiMC::installUpdates(const QString updateFilesDir, UpdateFlags flags) m_updateOnExitFlags = None; m_updateOnExitPath.clear(); } - QLOG_INFO() << "Installing updates."; + qDebug() << "Installing updates."; #ifdef WINDOWS QString finishCmd = applicationFilePath(); QString updaterBinary = PathCombine(applicationDirPath(), "updater.exe"); @@ -555,12 +574,12 @@ void MultiMC::installUpdates(const QString updateFilesDir, UpdateFlags flags) args << "--finish-cmd" << finishCmd; args << "--finish-dir" << dataPath; } - QLOG_INFO() << "Running updater with command" << updaterBinary << args.join(" "); + qDebug() << "Running updater with command" << updaterBinary << args.join(" "); QFile::setPermissions(updaterBinary, (QFileDevice::Permission)0x7755); if (!QProcess::startDetached(updaterBinary, args /*, root()*/)) { - QLOG_ERROR() << "Failed to start the updater process!"; + qCritical() << "Failed to start the updater process!"; return; } @@ -590,6 +609,11 @@ void MultiMC::onExit() installUpdates(m_updateOnExitPath, m_updateOnExitFlags); } ENV.destroy(); + if(logFile) + { + logFile->flush(); + logFile->close(); + } } bool MultiMC::openJsonEditor(const QString &filename) diff --git a/MultiMC.h b/MultiMC.h index 63eed83a..33aebab0 100644 --- a/MultiMC.h +++ b/MultiMC.h @@ -2,11 +2,12 @@ #include #include -#include "logger/QsLog.h" -#include "logger/QsLogDest.h" +#include #include #include +#include +class QFile; class MinecraftVersionList; class LWJGLVersionList; class HttpMetaCache; @@ -62,7 +63,10 @@ public: return m_settings; } - + qint64 timeSinceStart() const + { + return startTime.msecsTo(QDateTime::currentDateTime()); + } QIcon getThemedIcon(const QString& name); @@ -153,6 +157,8 @@ private: friend class UpdateCheckerTest; friend class DownloadUpdateTaskTest; + QDateTime startTime; + std::shared_ptr m_qt_translator; std::shared_ptr m_mmc_translator; std::shared_ptr m_settings; @@ -169,9 +175,6 @@ private: QMap> m_profilers; QMap> m_tools; - QsLogging::DestinationPtr m_fileDestination; - QsLogging::DestinationPtr m_debugDestination; - QString m_updateOnExitPath; UpdateFlags m_updateOnExitFlags = None; @@ -180,4 +183,6 @@ private: QString dataPath; Status m_status = MultiMC::Failed; +public: + std::shared_ptr logFile; }; diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index f0d882ba..2025a097 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -916,7 +916,7 @@ void MainWindow::updateAvailable(QString repo, QString versionName, int versionI switch (action) { case UPDATE_LATER: - QLOG_INFO() << "Update will be installed later."; + qDebug() << "Update will be installed later."; break; case UPDATE_NOW: downloadUpdates(repo, versionId); @@ -975,7 +975,7 @@ void MainWindow::notificationsChanged() void MainWindow::downloadUpdates(QString repo, int versionId, bool installOnExit) { - QLOG_INFO() << "Downloading updates."; + qDebug() << "Downloading updates."; // TODO: If the user chooses to update on exit, we should download updates in the // background. // Doing so is a bit complicated, because we'd have to make sure it finished downloading @@ -1086,7 +1086,7 @@ void MainWindow::instanceFromZipPack(QString instName, QString instGroup, QStrin QTemporaryDir extractTmpDir; QDir extractDir(extractTmpDir.path()); - QLOG_INFO() << "Attempting to create instance from" << archivePath; + qDebug() << "Attempting to create instance from" << archivePath; if (JlCompress::extractDir(archivePath, extractDir.absolutePath()).isEmpty()) { CustomMessageBox::selectable(this, tr("Error"), @@ -1730,7 +1730,7 @@ void MainWindow::doLaunch(bool online, BaseProfilerFactory *profiler) { case AuthSession::Undetermined: { - QLOG_ERROR() << "Received undetermined session status during login. Bye."; + qCritical() << "Received undetermined session status during login. Bye."; tryagain = false; break; } @@ -2004,7 +2004,7 @@ void MainWindow::checkSetDefaultJava() if (askForJava) { - QLOG_DEBUG() << "Java path needs resetting, showing Java selection dialog..."; + qDebug() << "Java path needs resetting, showing Java selection dialog..."; JavaVersionPtr java; diff --git a/gui/dialogs/AccountSelectDialog.cpp b/gui/dialogs/AccountSelectDialog.cpp index 4d10112e..6ae60738 100644 --- a/gui/dialogs/AccountSelectDialog.cpp +++ b/gui/dialogs/AccountSelectDialog.cpp @@ -18,7 +18,7 @@ #include -#include +#include #include @@ -40,7 +40,7 @@ AccountSelectDialog::AccountSelectDialog(const QString &message, int flags, QWid // Flags... ui->globalDefaultCheck->setVisible(flags & GlobalDefaultCheckbox); ui->instDefaultCheck->setVisible(flags & InstanceDefaultCheckbox); - QLOG_DEBUG() << flags; + qDebug() << flags; // Select the first entry in the list. ui->listView->setCurrentIndex(ui->listView->model()->index(0, 0)); diff --git a/gui/dialogs/UpdateDialog.cpp b/gui/dialogs/UpdateDialog.cpp index 29d09ead..1fcc156a 100644 --- a/gui/dialogs/UpdateDialog.cpp +++ b/gui/dialogs/UpdateDialog.cpp @@ -1,7 +1,7 @@ #include "UpdateDialog.h" #include "ui_UpdateDialog.h" #include "gui/Platform.h" -#include "logger/QsLog.h" +#include #include "MultiMC.h" #include @@ -82,7 +82,7 @@ QString reprocessMarkdown(QString markdown) html << "
    \n"; html << "
  • " << procLine(line.mid(2)) << "
  • \n"; } - else QLOG_ERROR() << "Invalid input on line " << i << ": " << line; + else qCritical() << "Invalid input on line " << i << ": " << line; break; case LIST1: if(line.startsWith("##")) @@ -107,7 +107,7 @@ QString reprocessMarkdown(QString markdown) html << "
      \n"; html << "
    • " << procLine(line.mid(4)) << "
    • \n"; } - else QLOG_ERROR() << "Invalid input on line " << i << ": " << line; + else qCritical() << "Invalid input on line " << i << ": " << line; break; case LIST2: if(line.startsWith("##")) @@ -134,7 +134,7 @@ QString reprocessMarkdown(QString markdown) { html << "
    • " << procLine(line.mid(4)) << "
    • \n"; } - else QLOG_ERROR() << "Invalid input on line " << i << ": " << line; + else qCritical() << "Invalid input on line " << i << ": " << line; break; } i++; @@ -151,10 +151,10 @@ QString reprocessMarkdown(QString markdown) } if (state != BASE) { - QLOG_ERROR() << "Reprocessing markdown didn't end in a final state!"; + qCritical() << "Reprocessing markdown didn't end in a final state!"; } html << "\n"; - QLOG_DEBUG() << htmlData; + qDebug() << htmlData; return htmlData; } diff --git a/gui/dialogs/VersionSelectDialog.cpp b/gui/dialogs/VersionSelectDialog.cpp index e9758d55..a0a58699 100644 --- a/gui/dialogs/VersionSelectDialog.cpp +++ b/gui/dialogs/VersionSelectDialog.cpp @@ -25,7 +25,7 @@ #include #include #include -#include "logger/QsLog.h" +#include class VersionSelectProxyModel : public QSortFilterProxyModel { diff --git a/gui/groupview/GroupView.cpp b/gui/groupview/GroupView.cpp index 502cf259..89694b87 100644 --- a/gui/groupview/GroupView.cpp +++ b/gui/groupview/GroupView.cpp @@ -12,7 +12,7 @@ #include #include "VisualGroup.h" -#include "logger/QsLog.h" +#include template bool listsIntersect(const QList &l1, const QList t2) { diff --git a/gui/groupview/GroupedProxyModel.cpp b/gui/groupview/GroupedProxyModel.cpp index 30845caa..a45c5ae9 100644 --- a/gui/groupview/GroupedProxyModel.cpp +++ b/gui/groupview/GroupedProxyModel.cpp @@ -1,7 +1,7 @@ #include "GroupedProxyModel.h" #include "GroupView.h" -#include "logger/QsLog.h" +#include GroupedProxyModel::GroupedProxyModel(QObject *parent) : QSortFilterProxyModel(parent) { @@ -21,16 +21,16 @@ bool GroupedProxyModel::lessThan(const QModelIndex &left, const QModelIndex &rig auto result = leftCategory.localeAwareCompare(rightCategory); if(result < 0) { - QLOG_DEBUG() << leftCategory << "<" << rightCategory; + qDebug() << leftCategory << "<" << rightCategory; } if(result == 0) { - QLOG_DEBUG() << leftCategory << "=" << rightCategory; + qDebug() << leftCategory << "=" << rightCategory; return subSortLessThan(left, right); } if(result > 0) { - QLOG_DEBUG() << leftCategory << ">" << rightCategory; + qDebug() << leftCategory << ">" << rightCategory; } return result < 0; } diff --git a/gui/pages/global/AccountListPage.cpp b/gui/pages/global/AccountListPage.cpp index 2de77115..72e18405 100644 --- a/gui/pages/global/AccountListPage.cpp +++ b/gui/pages/global/AccountListPage.cpp @@ -18,7 +18,7 @@ #include -#include +#include #include "logic/net/NetJob.h" #include "logic/net/URLConstants.h" diff --git a/gui/pages/global/MultiMCPage.cpp b/gui/pages/global/MultiMCPage.cpp index 3226de83..d2934666 100644 --- a/gui/pages/global/MultiMCPage.cpp +++ b/gui/pages/global/MultiMCPage.cpp @@ -212,7 +212,7 @@ void MultiMCPage::refreshUpdateChannelList() // the combo box to it. if (entry.id == m_currentUpdateChannel) { - QLOG_DEBUG() << "Selected index" << i << "channel id" << m_currentUpdateChannel; + qDebug() << "Selected index" << i << "channel id" << m_currentUpdateChannel; selection = i; } } diff --git a/logger/QsDebugOutput.cpp b/logger/QsDebugOutput.cpp deleted file mode 100644 index d68cd5e9..00000000 --- a/logger/QsDebugOutput.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2010, Razvan Petru -// All rights reserved. - -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: - -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, this -// list of conditions and the following disclaimer in the documentation and/or other -// materials provided with the distribution. -// * The name of the contributors may not be used to endorse or promote products -// derived from this software without specific prior written permission. - -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -// OF THE POSSIBILITY OF SUCH DAMAGE. - -#include "QsDebugOutput.h" -#include -#include - -#if defined(Q_OS_WIN) -#define WIN32_LEAN_AND_MEAN -#include -void QsDebugOutput::output(const QString &message) -{ - OutputDebugStringW(reinterpret_cast(message.utf16())); - OutputDebugStringW(L"\n"); -} -#elif defined(Q_OS_SYMBIAN) -#include -void QsDebugOutput::output(const QString &message) -{ - TPtrC8 symbianMessage(reinterpret_cast(qPrintable(message))); - RDebug::RawPrint(symbianMessage); -} -#elif defined(Q_OS_UNIX) -#include -void QsDebugOutput::output(const QString &message) -{ - fprintf(stderr, "%s\n", qPrintable(message)); - fflush(stderr); -} -#endif diff --git a/logger/QsDebugOutput.h b/logger/QsDebugOutput.h deleted file mode 100644 index 8c759a6d..00000000 --- a/logger/QsDebugOutput.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2010, Razvan Petru -// All rights reserved. - -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: - -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, this -// list of conditions and the following disclaimer in the documentation and/or other -// materials provided with the distribution. -// * The name of the contributors may not be used to endorse or promote products -// derived from this software without specific prior written permission. - -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -// OF THE POSSIBILITY OF SUCH DAMAGE. - -#pragma once - -class QString; - -class QsDebugOutput -{ -public: - static void output(const QString &a_message); -}; diff --git a/logger/QsLog.cpp b/logger/QsLog.cpp deleted file mode 100644 index 68493963..00000000 --- a/logger/QsLog.cpp +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright (c) 2010, Razvan Petru -// All rights reserved. - -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: - -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, this -// list of conditions and the following disclaimer in the documentation and/or other -// materials provided with the distribution. -// * The name of the contributors may not be used to endorse or promote products -// derived from this software without specific prior written permission. - -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -// OF THE POSSIBILITY OF SUCH DAMAGE. - -#include "QsLog.h" -#include "QsLogDest.h" -#include -#include -#include -#include -#include -#include -#include - -namespace QsLogging -{ -typedef QList DestinationList; - -static const char *LevelStrings[] = {"TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "UNKNOWN"}; - -static const char *LevelToText(Level theLevel) -{ - if (theLevel > FatalLevel) - { - assert(!"bad log level"); - return LevelStrings[UnknownLevel]; - } - return LevelStrings[theLevel]; -} - -class LoggerImpl -{ -public: - LoggerImpl() : level(InfoLevel) - { - } - QMutex logMutex; - Level level; - DestinationList destList; - QDateTime startTime; -}; - -Logger::Logger() : d(new LoggerImpl) -{ - d->startTime = QDateTime::currentDateTime(); -} - -Logger::~Logger() -{ - delete d; -} - -void Logger::addDestination(Destination *destination) -{ - assert(destination); - d->destList.push_back(destination); -} - -void Logger::setLoggingLevel(Level newLevel) -{ - d->level = newLevel; -} - -Level Logger::loggingLevel() const -{ - return d->level; -} - -QDateTime Logger::timeOfStart() const -{ - return d->startTime; -} - -qint64 Logger::timeSinceStart() const -{ - return d->startTime.msecsTo(QDateTime::currentDateTime()); -} - - -//! creates the complete log message and passes it to the logger -void Logger::Helper::writeToLog() -{ - const char *const levelName = LevelToText(level); - Logger &logger = Logger::instance(); - qint64 msecstotal = logger.timeSinceStart(); - qint64 seconds = msecstotal / 1000; - qint64 msecs = msecstotal % 1000; - QString foo; - char buf[1024]; - - ::snprintf(buf, 1024, "%5lld.%03lld", seconds, msecs); - - const QString completeMessage(QString("%1\t%2\t%3").arg(buf).arg(levelName, 5).arg(buffer)); - - QMutexLocker lock(&logger.d->logMutex); - logger.write(completeMessage); -} - -Logger::Helper::Helper(Level logLevel) : level(logLevel), qtDebug(&buffer) -{ -} - -Logger::Helper::~Helper() -{ - try - { - writeToLog(); - } - catch (std::exception &e) - { - // you shouldn't throw exceptions from a sink - Q_UNUSED(e); - assert(!"exception in logger helper destructor"); - throw; - } -} - -//! sends the message to all the destinations -void Logger::write(const QString &message) -{ - for (DestinationList::iterator it = d->destList.begin(), endIt = d->destList.end(); - it != endIt; ++it) - { - if (!(*it)) - { - assert(!"null log destination"); - continue; - } - (*it)->write(message); - } -} - -void Logger::removeDestination(Destination* destination) -{ - d->destList.removeAll(destination); -} - -} // end namespace diff --git a/logger/QsLog.h b/logger/QsLog.h deleted file mode 100644 index 2b7984e6..00000000 --- a/logger/QsLog.h +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright (c) 2010, Razvan Petru -// All rights reserved. - -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: - -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, this -// list of conditions and the following disclaimer in the documentation and/or other -// materials provided with the distribution. -// * The name of the contributors may not be used to endorse or promote products -// derived from this software without specific prior written permission. - -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -// OF THE POSSIBILITY OF SUCH DAMAGE. - -#pragma once - -#include -#include -#include - -namespace QsLogging -{ -class Destination; -enum Level -{ - TraceLevel = 0, - DebugLevel, - InfoLevel, - WarnLevel, - ErrorLevel, - FatalLevel, - UnknownLevel -}; - -class LoggerImpl; // d pointer -class Logger -{ -public: - static Logger &instance() - { - static Logger staticLog; - return staticLog; - } - - //! Adds a log message destination. Don't add null destinations. - void addDestination(Destination *destination); - //! Removes the given destination from the logger. - void removeDestination(Destination* destination); - //! Logging at a level < 'newLevel' will be ignored - void setLoggingLevel(Level newLevel); - //! The default level is INFO - Level loggingLevel() const; - //! msecs since the logger was initialized - qint64 timeSinceStart() const; - //! time when the logger was initialized - QDateTime timeOfStart() const; - - - //! The helper forwards the streaming to QDebug and builds the final - //! log message. - class Helper - { - public: - explicit Helper(Level logLevel); - ~Helper(); - QDebug &stream() - { - return qtDebug; - } - - private: - void writeToLog(); - - Level level; - QString buffer; - QDebug qtDebug; - }; - -private: - Logger(); - Logger(const Logger &); - Logger &operator=(const Logger &); - ~Logger(); - - void write(const QString &message); - - LoggerImpl *d; -}; - -} // end namespace - -#define QLOG_TRACE() \ - if (QsLogging::Logger::instance().loggingLevel() <= QsLogging::TraceLevel) \ - QsLogging::Logger::Helper(QsLogging::TraceLevel).stream() -#define QLOG_DEBUG() \ - if (QsLogging::Logger::instance().loggingLevel() <= QsLogging::DebugLevel) \ - QsLogging::Logger::Helper(QsLogging::DebugLevel).stream() -#define QLOG_INFO() \ - if (QsLogging::Logger::instance().loggingLevel() <= QsLogging::InfoLevel) \ - QsLogging::Logger::Helper(QsLogging::InfoLevel).stream() -#define QLOG_WARN() \ - if (QsLogging::Logger::instance().loggingLevel() <= QsLogging::WarnLevel) \ - QsLogging::Logger::Helper(QsLogging::WarnLevel).stream() -#define QLOG_ERROR() \ - if (QsLogging::Logger::instance().loggingLevel() <= QsLogging::ErrorLevel) \ - QsLogging::Logger::Helper(QsLogging::ErrorLevel).stream() -#define QLOG_FATAL() QsLogging::Logger::Helper(QsLogging::FatalLevel).stream() - -/* -#define QLOG_TRACE() \ - if (QsLogging::Logger::instance().loggingLevel() <= QsLogging::TraceLevel) \ - QsLogging::Logger::Helper(QsLogging::TraceLevel).stream() << __FILE__ << '@' << __LINE__ -#define QLOG_DEBUG() \ - if (QsLogging::Logger::instance().loggingLevel() <= QsLogging::DebugLevel) \ - QsLogging::Logger::Helper(QsLogging::DebugLevel).stream() << __FILE__ << '@' << __LINE__ -#define QLOG_INFO() \ - if (QsLogging::Logger::instance().loggingLevel() <= QsLogging::InfoLevel) \ - QsLogging::Logger::Helper(QsLogging::InfoLevel).stream() << __FILE__ << '@' << __LINE__ -#define QLOG_WARN() \ - if (QsLogging::Logger::instance().loggingLevel() <= QsLogging::WarnLevel) \ - QsLogging::Logger::Helper(QsLogging::WarnLevel).stream() << __FILE__ << '@' << __LINE__ -#define QLOG_ERROR() \ - if (QsLogging::Logger::instance().loggingLevel() <= QsLogging::ErrorLevel) \ - QsLogging::Logger::Helper(QsLogging::ErrorLevel).stream() << __FILE__ << '@' << __LINE__ -#define QLOG_FATAL() \ - QsLogging::Logger::Helper(QsLogging::FatalLevel).stream() << __FILE__ << '@' << __LINE__ -*/ diff --git a/logger/QsLogDest.cpp b/logger/QsLogDest.cpp deleted file mode 100644 index 4a47060e..00000000 --- a/logger/QsLogDest.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) 2010, Razvan Petru -// All rights reserved. - -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: - -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, this -// list of conditions and the following disclaimer in the documentation and/or other -// materials provided with the distribution. -// * The name of the contributors may not be used to endorse or promote products -// derived from this software without specific prior written permission. - -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -// OF THE POSSIBILITY OF SUCH DAMAGE. - -#include "QsLogDest.h" -#include "QsDebugOutput.h" -#include "QsLog.h" -#include -#include -#include - -namespace QsLogging -{ - -Destination::~Destination() -{ - Logger::instance().removeDestination(this); - QsDebugOutput::output("Removed logger destination."); -} - -//! file message sink -class FileDestination : public Destination -{ -public: - FileDestination(const QString &filePath); - virtual void write(const QString &message); - -private: - QFile mFile; - QTextStream mOutputStream; -}; - -FileDestination::FileDestination(const QString &filePath) -{ - mFile.setFileName(filePath); - mFile.open(QFile::WriteOnly | QFile::Text | - QFile::Truncate); // fixme: should throw on failure - mOutputStream.setDevice(&mFile); -} - -void FileDestination::write(const QString &message) -{ - mOutputStream << message << endl; - mOutputStream.flush(); -} - -//! debugger sink -class DebugOutputDestination : public Destination -{ -public: - virtual void write(const QString &message); -}; - -void DebugOutputDestination::write(const QString &message) -{ - QsDebugOutput::output(message); -} - -class QDebugDestination : public Destination -{ -public: - virtual void write(const QString &message) - { - qDebug() << message; - }; -}; - -DestinationPtr DestinationFactory::MakeFileDestination(const QString &filePath) -{ - return DestinationPtr(new FileDestination(filePath)); -} - -DestinationPtr DestinationFactory::MakeDebugOutputDestination() -{ - return DestinationPtr(new DebugOutputDestination); -} - -DestinationPtr DestinationFactory::MakeQDebugDestination() -{ - return DestinationPtr(new QDebugDestination); -} - -} // end namespace diff --git a/logger/QsLogDest.h b/logger/QsLogDest.h deleted file mode 100644 index a8000022..00000000 --- a/logger/QsLogDest.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2010, Razvan Petru -// All rights reserved. - -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: - -// * Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, this -// list of conditions and the following disclaimer in the documentation and/or other -// materials provided with the distribution. -// * The name of the contributors may not be used to endorse or promote products -// derived from this software without specific prior written permission. - -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -// OF THE POSSIBILITY OF SUCH DAMAGE. - -#pragma once - -#include - -class QString; - -namespace QsLogging -{ - -class Destination -{ -public: - virtual ~Destination(); - virtual void write(const QString &message) = 0; -}; -typedef std::shared_ptr DestinationPtr; - -//! Creates logging destinations/sinks. The caller will have ownership of -//! the newly created destinations. -class DestinationFactory -{ -public: - static DestinationPtr MakeFileDestination(const QString &filePath); - static DestinationPtr MakeDebugOutputDestination(); - static DestinationPtr MakeQDebugDestination(); -}; - -} // end namespace diff --git a/logic/BaseProcess.cpp b/logic/BaseProcess.cpp index d65e76d9..eb1bbfdc 100644 --- a/logic/BaseProcess.cpp +++ b/logic/BaseProcess.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ #include "logic/BaseProcess.h" -#include "logger/QsLog.h" +#include #include #include @@ -71,20 +71,20 @@ void BaseProcess::init() // filter out dangerous java crap if(ignored.contains(key)) { - QLOG_INFO() << "Env: ignoring" << key << value; + qDebug() << "Env: ignoring" << key << value; continue; } // filter MultiMC-related things if(key.startsWith("QT_")) { - QLOG_INFO() << "Env: ignoring" << key << value; + qDebug() << "Env: ignoring" << key << value; continue; } #ifdef LINUX // Do not pass LD_* variables to java. They were intended for MultiMC if(key.startsWith("LD_")) { - QLOG_INFO() << "Env: ignoring" << key << value; + qDebug() << "Env: ignoring" << key << value; continue; } // Strip IBus @@ -93,10 +93,10 @@ void BaseProcess::init() { QString save = value; value.replace(IBUS, ""); - QLOG_INFO() << "Env: stripped" << IBUS << "from" << save << ":" << value; + qDebug() << "Env: stripped" << IBUS << "from" << save << ":" << value; } #endif - QLOG_INFO() << "Env: " << key << value; + qDebug() << "Env: " << key << value; env.insert(key, value); } #ifdef LINUX diff --git a/logic/Env.cpp b/logic/Env.cpp index 68e76e4b..69986be2 100644 --- a/logic/Env.cpp +++ b/logic/Env.cpp @@ -6,7 +6,7 @@ #include #include #include -#include "logger/QsLog.h" +#include #include "logic/tasks/Task.h" #include @@ -175,14 +175,14 @@ void Env::updateProxySettings(QString proxyTypeStr, QString addr, int port, QStr QNetworkProxyFactory::setUseSystemConfiguration(true); } - QLOG_INFO() << "Detecting proxy settings..."; + qDebug() << "Detecting proxy settings..."; QNetworkProxy proxy = QNetworkProxy::applicationProxy(); if (m_qnam.get()) m_qnam->setProxy(proxy); QString proxyDesc; if (proxy.type() == QNetworkProxy::NoProxy) { - QLOG_INFO() << "Using no proxy is an option!"; + qDebug() << "Using no proxy is an option!"; return; } switch (proxy.type()) @@ -211,7 +211,7 @@ void Env::updateProxySettings(QString proxyTypeStr, QString addr, int port, QStr .arg(proxy.port()) .arg(proxy.user()) .arg(proxy.password()); - QLOG_INFO() << proxyDesc; + qDebug() << proxyDesc; } #include "Env.moc" \ No newline at end of file diff --git a/logic/InstanceList.cpp b/logic/InstanceList.cpp index 657fd5b4..ef6594d9 100644 --- a/logic/InstanceList.cpp +++ b/logic/InstanceList.cpp @@ -34,7 +34,7 @@ #include "settings/INISettingsObject.h" #include "OneSixInstance.h" #include "LegacyInstance.h" -#include "logger/QsLog.h" +#include const static int GROUP_FILE_FORMAT_VERSION = 1; @@ -138,7 +138,7 @@ void InstanceList::saveGroupList() if (!groupFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) { // An error occurred. Ignore it. - QLOG_ERROR() << "Failed to save instance group file."; + qCritical() << "Failed to save instance group file."; return; } QTextStream out(&groupFile); @@ -202,7 +202,7 @@ void InstanceList::loadGroupList(QMap &groupMap) if (!groupFile.open(QIODevice::ReadOnly)) { // An error occurred. Ignore it. - QLOG_ERROR() << "Failed to read instance group file."; + qCritical() << "Failed to read instance group file."; return; } @@ -216,7 +216,7 @@ void InstanceList::loadGroupList(QMap &groupMap) // if the json was bad, fail if (error.error != QJsonParseError::NoError) { - QLOG_ERROR() << QString("Failed to parse instance group file: %1 at offset %2") + qCritical() << QString("Failed to parse instance group file: %1 at offset %2") .arg(error.errorString(), QString::number(error.offset)) .toUtf8(); return; @@ -225,7 +225,7 @@ void InstanceList::loadGroupList(QMap &groupMap) // if the root of the json wasn't an object, fail if (!jsonDoc.isObject()) { - QLOG_WARN() << "Invalid group file. Root entry should be an object."; + qWarning() << "Invalid group file. Root entry should be an object."; return; } @@ -238,7 +238,7 @@ void InstanceList::loadGroupList(QMap &groupMap) // Get the groups. if it's not an object, fail if (!rootObj.value("groups").isObject()) { - QLOG_WARN() << "Invalid group list JSON: 'groups' should be an object."; + qWarning() << "Invalid group list JSON: 'groups' should be an object."; return; } @@ -251,7 +251,7 @@ void InstanceList::loadGroupList(QMap &groupMap) // If not an object, complain and skip to the next one. if (!iter.value().isObject()) { - QLOG_WARN() << QString("Group '%1' in the group list should " + qWarning() << QString("Group '%1' in the group list should " "be an object.") .arg(groupName) .toUtf8(); @@ -261,7 +261,7 @@ void InstanceList::loadGroupList(QMap &groupMap) QJsonObject groupObj = iter.value().toObject(); if (!groupObj.value("instances").isArray()) { - QLOG_WARN() << QString("Group '%1' in the group list is invalid. " + qWarning() << QString("Group '%1' in the group list is invalid. " "It should contain an array " "called 'instances'.") .arg(groupName) @@ -298,7 +298,7 @@ InstanceList::InstListError InstanceList::loadList() QString subDir = iter.next(); if (!QFileInfo(PathCombine(subDir, "instance.cfg")).exists()) continue; - QLOG_INFO() << "Loading MultiMC instance from " << subDir; + qDebug() << "Loading MultiMC instance from " << subDir; InstancePtr instPtr; auto error = loadInstance(instPtr, subDir); if(!continueProcessInstance(instPtr, error, subDir, groupMap)) @@ -410,12 +410,12 @@ bool InstanceList::continueProcessInstance(InstancePtr instPtr, const int error, errorMsg += QString("Unknown instance loader error %1").arg(error); break; } - QLOG_ERROR() << errorMsg.toUtf8(); + qCritical() << errorMsg.toUtf8(); return false; } else if (!instPtr) { - QLOG_ERROR() << QString("Error loading instance %1. Instance loader returned null.") + qCritical() << QString("Error loading instance %1. Instance loader returned null.") .arg(QFileInfo(dir.absolutePath()).baseName()) .toUtf8(); return false; @@ -427,7 +427,7 @@ bool InstanceList::continueProcessInstance(InstancePtr instPtr, const int error, { instPtr->setGroupInitial((*iter)); } - QLOG_INFO() << "Loaded instance " << instPtr->name() << " from " << dir.absolutePath(); + qDebug() << "Loaded instance " << instPtr->name() << " from " << dir.absolutePath(); return true; } } @@ -463,16 +463,16 @@ InstanceList::createInstance(InstancePtr &inst, BaseVersionPtr version, const QS { QDir rootDir(instDir); - QLOG_DEBUG() << instDir.toUtf8(); + qDebug() << instDir.toUtf8(); if (!rootDir.exists() && !rootDir.mkpath(".")) { - QLOG_ERROR() << "Can't create instance folder" << instDir; + qCritical() << "Can't create instance folder" << instDir; return InstanceList::CantCreateDir; } if (!version) { - QLOG_ERROR() << "Can't create instance for non-existing MC version"; + qCritical() << "Can't create instance for non-existing MC version"; return InstanceList::NoSuchVersion; } @@ -497,7 +497,7 @@ InstanceList::copyInstance(InstancePtr &newInstance, InstancePtr &oldInstance, c { QDir rootDir(instDir); - QLOG_DEBUG() << instDir.toUtf8(); + qDebug() << instDir.toUtf8(); if (!copyPath(oldInstance->instanceRoot(), instDir)) { rootDir.removeRecursively(); diff --git a/logic/JarUtils.cpp b/logic/JarUtils.cpp index d4f1ed56..e73af53c 100644 --- a/logic/JarUtils.cpp +++ b/logic/JarUtils.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include namespace JarUtils { @@ -19,13 +19,13 @@ bool mergeZipFiles(QuaZip *into, QFileInfo from, QSet &contained, QString filename = modZip.getCurrentFileName(); if (!filter(filename)) { - QLOG_INFO() << "Skipping file " << filename << " from " + qDebug() << "Skipping file " << filename << " from " << from.fileName() << " - filtered"; continue; } if (contained.contains(filename)) { - QLOG_INFO() << "Skipping already contained file " << filename << " from " + qDebug() << "Skipping already contained file " << filename << " from " << from.fileName(); continue; } @@ -33,7 +33,7 @@ bool mergeZipFiles(QuaZip *into, QFileInfo from, QSet &contained, if (!fileInsideMod.open(QIODevice::ReadOnly)) { - QLOG_ERROR() << "Failed to open " << filename << " from " << from.fileName(); + qCritical() << "Failed to open " << filename << " from " << from.fileName(); return false; } @@ -41,7 +41,7 @@ bool mergeZipFiles(QuaZip *into, QFileInfo from, QSet &contained, if (!zipOutFile.open(QIODevice::WriteOnly, info_out)) { - QLOG_ERROR() << "Failed to open " << filename << " in the jar"; + qCritical() << "Failed to open " << filename << " in the jar"; fileInsideMod.close(); return false; } @@ -49,7 +49,7 @@ bool mergeZipFiles(QuaZip *into, QFileInfo from, QSet &contained, { zipOutFile.close(); fileInsideMod.close(); - QLOG_ERROR() << "Failed to copy data of " << filename << " into the jar"; + qCritical() << "Failed to copy data of " << filename << " into the jar"; return false; } zipOutFile.close(); @@ -64,7 +64,7 @@ bool createModdedJar(QString sourceJarPath, QString targetJarPath, const QList LegacyInstance::getJarMods() const void LegacyInstance::jarModsChanged() { - QLOG_INFO() << "Jar mods of instance " << name() << " have changed. Jar will be rebuilt."; + qDebug() << "Jar mods of instance " << name() << " have changed. Jar will be rebuilt."; setShouldRebuild(true); } diff --git a/logic/LegacyUpdate.cpp b/logic/LegacyUpdate.cpp index e12556eb..8b970f08 100644 --- a/logic/LegacyUpdate.cpp +++ b/logic/LegacyUpdate.cpp @@ -28,7 +28,7 @@ #include "logic/Env.h" #include "logic/ModList.h" -#include "logger/QsLog.h" +#include #include "logic/net/URLConstants.h" #include "JarUtils.h" diff --git a/logic/LwjglVersionList.cpp b/logic/LwjglVersionList.cpp index 5bd9faa2..9e101b74 100644 --- a/logic/LwjglVersionList.cpp +++ b/logic/LwjglVersionList.cpp @@ -20,7 +20,7 @@ #include #include -#include "logger/QsLog.h" +#include #define RSS_URL "http://sourceforge.net/projects/java-game-lib/rss" @@ -131,7 +131,7 @@ void LWJGLVersionList::netRequestComplete() QDomElement linkElement = getDomElementByTagName(items.at(i).toElement(), "link"); if (linkElement.isNull()) { - QLOG_INFO() << "Link element" << i << "in RSS feed doesn't exist! Skipping."; + qDebug() << "Link element" << i << "in RSS feed doesn't exist! Skipping."; continue; } @@ -147,10 +147,10 @@ void LWJGLVersionList::netRequestComplete() QUrl url(link); if (!url.isValid()) { - QLOG_WARN() << "LWJGL version URL isn't valid:" << link << "Skipping."; + qWarning() << "LWJGL version URL isn't valid:" << link << "Skipping."; continue; } - QLOG_INFO() << "Discovered LWGL version" << name << "at" << link; + qDebug() << "Discovered LWGL version" << name << "at" << link; tempList.append(std::make_shared(name, link)); } } @@ -159,7 +159,7 @@ void LWJGLVersionList::netRequestComplete() m_vlist.swap(tempList); endResetModel(); - QLOG_INFO() << "Loaded LWJGL list."; + qDebug() << "Loaded LWJGL list."; finished(); } else @@ -173,7 +173,7 @@ void LWJGLVersionList::netRequestComplete() void LWJGLVersionList::failed(QString msg) { - QLOG_ERROR() << msg; + qCritical() << msg; emit loadListFailed(msg); } diff --git a/logic/Mod.cpp b/logic/Mod.cpp index 7fdd2a5e..7fa4905e 100644 --- a/logic/Mod.cpp +++ b/logic/Mod.cpp @@ -25,7 +25,7 @@ #include "Mod.h" #include #include "logic/settings/INIFile.h" -#include "logger/QsLog.h" +#include Mod::Mod(const QFileInfo &file) { @@ -209,8 +209,8 @@ void Mod::ReadMCModInfo(QByteArray contents) int version = val.toDouble(); if (version != 2) { - QLOG_ERROR() << "BAD stuff happened to mod json:"; - QLOG_ERROR() << contents; + qCritical() << "BAD stuff happened to mod json:"; + qCritical() << contents; return; } auto arrVal = jsonDoc.object().value("modlist"); @@ -273,7 +273,7 @@ bool Mod::replace(Mod &with) if (t == MOD_ZIPFILE || t == MOD_SINGLEFILE || t == MOD_LITEMOD) { - QLOG_DEBUG() << "Copy: " << with.m_file.filePath() << " to " << m_file.filePath(); + qDebug() << "Copy: " << with.m_file.filePath() << " to " << m_file.filePath(); success = QFile::copy(with.m_file.filePath(), m_file.filePath()); } if (t == MOD_FOLDER) diff --git a/logic/ModList.cpp b/logic/ModList.cpp index f6037c95..68d74e79 100644 --- a/logic/ModList.cpp +++ b/logic/ModList.cpp @@ -21,7 +21,7 @@ #include #include #include -#include "logger/QsLog.h" +#include ModList::ModList(const QString &dir, const QString &list_file) : QAbstractListModel(), m_dir(dir), m_list_file(list_file) @@ -42,11 +42,11 @@ void ModList::startWatching() is_watching = m_watcher->addPath(m_dir.absolutePath()); if (is_watching) { - QLOG_INFO() << "Started watching " << m_dir.absolutePath(); + qDebug() << "Started watching " << m_dir.absolutePath(); } else { - QLOG_INFO() << "Failed to start watching " << m_dir.absolutePath(); + qDebug() << "Failed to start watching " << m_dir.absolutePath(); } } @@ -55,11 +55,11 @@ void ModList::stopWatching() is_watching = !m_watcher->removePath(m_dir.absolutePath()); if (!is_watching) { - QLOG_INFO() << "Stopped watching " << m_dir.absolutePath(); + qDebug() << "Stopped watching " << m_dir.absolutePath(); } else { - QLOG_INFO() << "Failed to stop watching " << m_dir.absolutePath(); + qDebug() << "Failed to stop watching " << m_dir.absolutePath(); } } @@ -162,7 +162,7 @@ bool ModList::update() endResetModel(); if (orderOrStateChanged && !m_list_file.isEmpty()) { - QLOG_INFO() << "Mod list " << m_list_file << " changed!"; + qDebug() << "Mod list " << m_list_file << " changed!"; saveListFile(); emit changed(); } @@ -559,7 +559,7 @@ bool ModList::dropMimeData(const QMimeData *data, Qt::DropAction action, int row row = rowCount(); if (column == -1) column = 0; - QLOG_INFO() << "Drop row: " << row << " column: " << column; + qDebug() << "Drop row: " << row << " column: " << column; // files dropped from outside? if (data->hasUrls()) @@ -575,7 +575,7 @@ bool ModList::dropMimeData(const QMimeData *data, Qt::DropAction action, int row continue; QString filename = url.toLocalFile(); installMod(filename, row); - QLOG_INFO() << "installing: " << filename; + qDebug() << "installing: " << filename; // if there is no ordering, re-sort the list if (m_list_file.isEmpty()) { @@ -596,7 +596,7 @@ bool ModList::dropMimeData(const QMimeData *data, Qt::DropAction action, int row return false; QString remoteId = list[0]; int remoteIndex = list[1].toInt(); - QLOG_INFO() << "move: " << sourcestr; + qDebug() << "move: " << sourcestr; // no moving of things between two lists if (remoteId != m_list_id) return false; diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp index bdd47131..642a6aec 100644 --- a/logic/OneSixInstance.cpp +++ b/logic/OneSixInstance.cpp @@ -15,7 +15,7 @@ #include #include -#include "logger/QsLog.h" +#include #include "MMCError.h" #include "logic/OneSixInstance.h" diff --git a/logic/OneSixUpdate.cpp b/logic/OneSixUpdate.cpp index 38e9c0d7..5ec36305 100644 --- a/logic/OneSixUpdate.cpp +++ b/logic/OneSixUpdate.cpp @@ -60,14 +60,14 @@ void OneSixUpdate::executeTask() } if (m_inst->providesVersionFile() || !targetVersion->needsUpdate()) { - QLOG_DEBUG() << "Instance either provides a version file or doesn't need an update."; + qDebug() << "Instance either provides a version file or doesn't need an update."; jarlibStart(); return; } versionUpdateTask = std::dynamic_pointer_cast(ENV.getVersionList("net.minecraft"))->createUpdateTask(m_inst->intendedVersionId()); if (!versionUpdateTask) { - QLOG_DEBUG() << "Didn't spawn an update task."; + qDebug() << "Didn't spawn an update task."; jarlibStart(); return; } @@ -173,7 +173,7 @@ void OneSixUpdate::assetsFailed() void OneSixUpdate::jarlibStart() { setStatus(tr("Getting the library files from Mojang...")); - QLOG_INFO() << m_inst->name() << ": downloading libraries"; + qDebug() << m_inst->name() << ": downloading libraries"; OneSixInstance *inst = (OneSixInstance *)m_inst; try { diff --git a/logic/assets/AssetsUtils.cpp b/logic/assets/AssetsUtils.cpp index 82a0da95..9f33b1bd 100644 --- a/logic/assets/AssetsUtils.cpp +++ b/logic/assets/AssetsUtils.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include "AssetsUtils.h" #include @@ -85,7 +85,7 @@ bool loadAssetsIndexJson(QString path, AssetsIndex *index) // TODO: We should probably report this error to the user. if (!file.open(QIODevice::ReadOnly)) { - QLOG_ERROR() << "Failed to read assets index file" << path; + qCritical() << "Failed to read assets index file" << path; return false; } @@ -99,7 +99,7 @@ bool loadAssetsIndexJson(QString path, AssetsIndex *index) // Fail if the JSON is invalid. if (parseError.error != QJsonParseError::NoError) { - QLOG_ERROR() << "Failed to parse assets index file:" << parseError.errorString() + qCritical() << "Failed to parse assets index file:" << parseError.errorString() << "at offset " << QString::number(parseError.offset); return false; } @@ -107,7 +107,7 @@ bool loadAssetsIndexJson(QString path, AssetsIndex *index) // Make sure the root is an object. if (!jsonDoc.isObject()) { - QLOG_ERROR() << "Invalid assets index JSON: Root should be an array."; + qCritical() << "Invalid assets index JSON: Root should be an array."; return false; } @@ -124,7 +124,7 @@ bool loadAssetsIndexJson(QString path, AssetsIndex *index) for (QVariantMap::const_iterator iter = map.begin(); iter != map.end(); ++iter) { - // QLOG_DEBUG() << iter.key(); + // qDebug() << iter.key(); QVariant variant = iter.value(); QVariantMap nested_objects = variant.toMap(); @@ -134,7 +134,7 @@ bool loadAssetsIndexJson(QString path, AssetsIndex *index) for (QVariantMap::const_iterator nested_iter = nested_objects.begin(); nested_iter != nested_objects.end(); ++nested_iter) { - // QLOG_DEBUG() << nested_iter.key() << nested_iter.value().toString(); + // qDebug() << nested_iter.key() << nested_iter.value().toString(); QString key = nested_iter.key(); QVariant value = nested_iter.value(); @@ -167,11 +167,11 @@ QDir reconstructAssets(QString assetsId) if (!indexFile.exists()) { - QLOG_ERROR() << "No assets index file" << indexPath << "; can't reconstruct assets"; + qCritical() << "No assets index file" << indexPath << "; can't reconstruct assets"; return virtualRoot; } - QLOG_DEBUG() << "reconstructAssets" << assetsDir.path() << indexDir.path() + qDebug() << "reconstructAssets" <<