Implement "--debug" to print qInfo(), qDebug(), console.info() and console.debug() messages

Note that setting "*.debug=true" leads the whole Qt's debug output being printed, which is NOT recommened.
This commit is contained in:
Matti Viljanen 2020-03-23 04:18:44 +02:00
parent 84728c0910
commit 6c436c3c12
No known key found for this signature in database
GPG key ID: CF32A1495158F888
2 changed files with 5 additions and 3 deletions

View file

@ -21,6 +21,9 @@ VERSION = $${VER}-$${REL}
$$system(bash update-spec-version.sh $$TARGET $$VER $$REL)
DEFINES += APP_VERSION=\"\\\"$$VERSION\\\"\"
# Do not set this! Use "--verbose" and "--debug" instead.
#DEFINES += QT_NO_DEBUG_OUTPUT
HEADERS += \
src/battery.h \
src/settings.h

View file

@ -52,6 +52,8 @@ int main(int argc, char *argv[])
}
else if(!strcmp(argv[i],"--verbose"))
qputenv(logEnvVar, "*.info=true;*.debug=false");
else if(!strcmp(argv[i],"--debug"))
qputenv(logEnvVar, "*.info=true");
}
if(!qEnvironmentVariableIsSet(logEnvVar))
qputenv(logEnvVar, "*.info=false;*.debug=false");
@ -60,9 +62,6 @@ int main(int argc, char *argv[])
QGuiApplication* app = SailfishApp::application(argc, argv);
QQuickView* view = SailfishApp::createView();
qDebug() << "Application name:" << app->applicationName();
qDebug() << "Organization name:" << app->organizationName();
Settings* settings = new Settings();
Battery* battery = new Battery(settings);