From 2eed11e1130c2976d0e18262cbad6e7634e35426 Mon Sep 17 00:00:00 2001 From: Qv2ray-Bot <59914293+Qv2ray-Bot@users.noreply.github.com> Date: Tue, 28 Jan 2020 20:30:56 +0800 Subject: [PATCH] fix: fixed release build log message --- Build.Counter | 2 +- src/components/QvCore/QvCommandLineArgs.cpp | 8 ++++---- src/main.cpp | 16 ++++++---------- src/utils/QvHelpers.cpp | 18 ++++++++++++++++-- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/Build.Counter b/Build.Counter index bf8f8525..d9d811cb 100644 --- a/Build.Counter +++ b/Build.Counter @@ -1 +1 @@ -3097 +3100 diff --git a/src/components/QvCore/QvCommandLineArgs.cpp b/src/components/QvCore/QvCommandLineArgs.cpp index 61a3ae90..070bbee5 100644 --- a/src/components/QvCore/QvCommandLineArgs.cpp +++ b/src/components/QvCore/QvCommandLineArgs.cpp @@ -43,22 +43,22 @@ namespace Qv2ray return CommandLineHelpRequested; if (parser.isSet(noAPIOption)) { - DEBUG(MODULE_INIT, "No API subsystem is set.") + DEBUG(MODULE_INIT, "noAPIOption is set.") StartupOption.noAPI = true; } if (parser.isSet(runAsRootOption)) { - DEBUG(MODULE_INIT, "Force run as root is set.") + DEBUG(MODULE_INIT, "runAsRootOption is set.") StartupOption.forceRunAsRootUser = true; } if (parser.isSet(debugOption)) { - DEBUG(MODULE_INIT, "Debug log is set.") + DEBUG(MODULE_INIT, "debugOption is set.") StartupOption.debugLog = true; } if (parser.isSet(withToolbarOption)) { - DEBUG(MODULE_INIT, "Run with network toolbar is set.") + DEBUG(MODULE_INIT, "withToolbarOption is set.") StartupOption.enableToolbarPlguin = true; } diff --git a/src/main.cpp b/src/main.cpp index 1e19d1d9..8f0910f9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,7 +31,7 @@ bool verifyConfigAvaliability(QString path, bool checkExistingConfig) LOG(MODULE_INIT, "---> Cannot create a new file or openwrite a file.") return false; } else { - testFile.write("qv2ray test file, feel free to remove."); + testFile.write("Qv2ray test file, feel free to remove."); testFile.flush(); testFile.close(); bool removed = testFile.remove(); @@ -249,13 +249,6 @@ int main(int argc, char *argv[]) isDebug = true; SingleApplication::setApplicationName("Qv2ray - DEBUG"); #endif - - // - if (StartupOption.debugLog) { - DEBUG(MODULE_INIT, "Debug log enabled") - } - - // SingleApplication _qApp(argc, argv, false, SingleApplication::Mode::User | SingleApplication::Mode::ExcludeAppPath | SingleApplication::Mode::ExcludeAppVersion); // Early initialisation // @@ -285,11 +278,14 @@ int main(int argc, char *argv[]) "Copyright (c) 2020 Itay Grudev (@itay-grudev): SingleApplication (MIT)" NEWLINE "Copyright (c) 2020 paceholder (@paceholder): nodeeditor (QNodeEditor modified by lhy0403) (BSD-3-Clause)" NEWLINE "Copyright (c) 2019 TheWanderingCoel (@TheWanderingCoel): ShadowClash (launchatlogin) (GPLv3)" NEWLINE - "Copyright (c) 2020 Ram Pani (@DuckSoft): **QvRPCBridge** (WTFPL)" NEWLINE + "Copyright (c) 2020 Ram Pani (@DuckSoft): QvRPCBridge (WTFPL)" NEWLINE NEWLINE) // LOG(MODULE_INIT, "Qv2ray Start Time: " + QSTRN(QTime::currentTime().msecsSinceStartOfDay())) - DEBUG("DEBUG", "WARNING: ============================== This is a debug build, many features are not stable enough. ==============================") + // +#ifdef QT_DEBUG + cout << "WARNING: ============================== This is a debug build, many features are not stable enough. ==============================" << endl; +#endif // // Load the language translation list. auto langs = GetFileList(QDir(":/translations")); diff --git a/src/utils/QvHelpers.cpp b/src/utils/QvHelpers.cpp index 5ac945bc..85a40fc7 100644 --- a/src/utils/QvHelpers.cpp +++ b/src/utils/QvHelpers.cpp @@ -8,9 +8,23 @@ static QQueue __loggerBuffer; void __QV2RAY_LOG_FUNC__(int type, const std::string &func, int line, const QString &module, const QString &log) { auto logString = "[" + module + "]: " + log; + auto funcPrepend = QString::fromStdString(func + ":" + to_string(line) + " "); - if (StartupOption.debugLog || (isDebug && type == QV2RAY_LOG_DEBUG)) { - logString.prepend(QString::fromStdString(func + ":" + to_string(line) + " ")); + if (isDebug) { + // Debug build version, we only print info for DEBUG logs and print ALL info when debugLog presents, + if (type == QV2RAY_LOG_DEBUG || StartupOption.debugLog) { + logString = logString.prepend(funcPrepend); + } + } else { + // We only process DEBUG log in Release mode + if (type == QV2RAY_LOG_DEBUG) { + if (StartupOption.debugLog) { + logString = logString.prepend(funcPrepend); + } else { + // Discard debug log in non-debug Qv2ray version with no-debugLog mode. + return; + } + } } cout << logString.toStdString() << endl;