diff options
author | Daniel d'Andrada <daniel.dandrada@luxoft.com> | 2017-09-29 10:05:25 +0200 |
---|---|---|
committer | Daniel d'Andrada <daniel.dandrada@luxoft.com> | 2017-10-04 15:28:47 +0000 |
commit | 4b24e3524bc1b3626eec522f379d86f68ad9099c (patch) | |
tree | 3fe18915d892c9d9408aae00d7f02376b11b3ee5 | |
parent | deef8a3c708122c27116860afd292dce0edfad89 (diff) |
Use categorized logging everywhere
Task-number: QTAUTO-551
Change-Id: If4d9f6c2adc930a00ff80010798cd9420d1e22df
Reviewed-by: Bramastyo Harimukti Santoso <bramastyo.harimukti.santoso@pelagicore.com>
37 files changed, 233 insertions, 90 deletions
diff --git a/apps/com.pelagicore.movies/MovieTracks.qml b/apps/com.pelagicore.movies/MovieTracks.qml index aff59a9..367f63c 100644 --- a/apps/com.pelagicore.movies/MovieTracks.qml +++ b/apps/com.pelagicore.movies/MovieTracks.qml @@ -141,6 +141,6 @@ UIScreen { Component.onCompleted: { MovieModel.selectRandom() view.model = MovieModel.model - console.log("Movie Tracks completed") + console.log(Logging.apps, "Movie Tracks completed") } } diff --git a/apps/com.pelagicore.movies/models/MovieModel.qml b/apps/com.pelagicore.movies/models/MovieModel.qml index e3bca02..5df2bdb 100644 --- a/apps/com.pelagicore.movies/models/MovieModel.qml +++ b/apps/com.pelagicore.movies/models/MovieModel.qml @@ -32,6 +32,7 @@ pragma Singleton import QtQuick 2.6 import com.pelagicore.datasource 1.0 +import utils 1.0 SqlQueryDataSource { id: root @@ -57,12 +58,12 @@ SqlQueryDataSource { } function next() { - console.log('$movies.nextTrack()') + console.log(Logging.apps, '$movies.nextTrack()') root.currentIndex++ } function previous() { - console.log('$movies.previousTrack()') + console.log(Logging.apps, '$movies.previousTrack()') root.currentIndex-- } } diff --git a/apps/com.pelagicore.music/LibraryList.qml b/apps/com.pelagicore.music/LibraryList.qml index 8ee6ad2..37d02b1 100644 --- a/apps/com.pelagicore.music/LibraryList.qml +++ b/apps/com.pelagicore.music/LibraryList.qml @@ -48,7 +48,7 @@ Control { property bool nowPlaying: false property SearchAndBrowseModel model: SearchAndBrowseModel { contentType: "" - onContentTypeChanged: print("CONTENT TYPE CHANGE: ", contentType) + onContentTypeChanged: console.log(Logging.apps, "CONTENT TYPE CHANGE: ", contentType) serviceObject: MusicModel.player.serviceObject } diff --git a/apps/com.pelagicore.music/models/MusicModel.qml b/apps/com.pelagicore.music/models/MusicModel.qml index 7e2cbcd..3bea129 100644 --- a/apps/com.pelagicore.music/models/MusicModel.qml +++ b/apps/com.pelagicore.music/models/MusicModel.qml @@ -35,6 +35,7 @@ import QtApplicationManager 1.0 import com.pelagicore.datasource 1.0 import QtIvi 1.0 import QtIvi.Media 1.0 +import utils 1.0 QtObject { id: root @@ -57,7 +58,7 @@ QtObject { } onRowsInserted: { - print("ROW INSERTED: NEW INDEX: ", first) + console.log(Logging.apps, "ROW INSERTED: NEW INDEX: ", first) player.playQueue.currentIndex = first; } } @@ -73,12 +74,12 @@ QtObject { property bool repeatOn: player.playMode === MediaPlayer.RepeatTrack function next() { - print('MusicModel.nextTrack()') + console.log(Logging.apps, 'MusicModel.nextTrack()') player.next() } function previous() { - print('MusicModel.previousTrack()') + console.log(Logging.apps, 'MusicModel.previousTrack()') player.previous() } diff --git a/apps/com.theqtcompany.i18ndemo/I18NDemo.qml b/apps/com.theqtcompany.i18ndemo/I18NDemo.qml index 977bee3..e4b9532 100644 --- a/apps/com.theqtcompany.i18ndemo/I18NDemo.qml +++ b/apps/com.theqtcompany.i18ndemo/I18NDemo.qml @@ -44,7 +44,7 @@ AppUIScreen { ComTQCi18nDemo { id: ctd onLanguageLocaleChanged: { - console.log("Locale changed " + languageLocale) + console.log(Logging.apps, "Locale changed " + languageLocale) } } diff --git a/apps/com.theqtcompany.i18ndemo/Languages.qml b/apps/com.theqtcompany.i18ndemo/Languages.qml index 1f9b4ff..19f0407 100644 --- a/apps/com.theqtcompany.i18ndemo/Languages.qml +++ b/apps/com.theqtcompany.i18ndemo/Languages.qml @@ -119,7 +119,7 @@ UIPage { onClicked: langSelectView.currentIndex = index } onCurrentIndexChanged: { - console.log("Index changed " + currentIndex) + console.log(Logging.apps, "Index changed " + currentIndex) ctd.languageLocale = langList.get(currentIndex)?langList.get(currentIndex).language:"" VirtualKeyboardSettings.locale = ctd.languageLocale } @@ -274,6 +274,6 @@ UIPage { } } Component.onCompleted: { - console.log("RowLayout completed " + ctd.languageLocale) + console.log(Logging.apps, "RowLayout completed " + ctd.languageLocale) } } diff --git a/examples/com.pelagicore.sheets/boards/AppButtonBoard.qml b/examples/com.pelagicore.sheets/boards/AppButtonBoard.qml index d593447..fe34fed 100644 --- a/examples/com.pelagicore.sheets/boards/AppButtonBoard.qml +++ b/examples/com.pelagicore.sheets/boards/AppButtonBoard.qml @@ -47,7 +47,7 @@ BaseBoard { AppButton { icon: Style.icon("widgets_phone") name: "Hello World" - onClicked: print("Clicked") + onClicked: console.log(Logging.apps,"Clicked") } AppButton { @@ -65,7 +65,7 @@ BaseBoard { icon: Style.icon("widgets_phone") name: "Edit Mode" editMode: true - onRemoveClicked: print("Remove clicked") + onRemoveClicked: console.log(Logging.apps,"Remove clicked") } } } diff --git a/examples/com.pelagicore.sheets/boards/ButtonBoard.qml b/examples/com.pelagicore.sheets/boards/ButtonBoard.qml index bda6695..858f575 100644 --- a/examples/com.pelagicore.sheets/boards/ButtonBoard.qml +++ b/examples/com.pelagicore.sheets/boards/ButtonBoard.qml @@ -107,7 +107,7 @@ BaseBoard { text: qsTr("Button") width: Style.hspan(3) - onClicked: console.log("Button Clicked!"); + onClicked: console.log(Logging.apps, "Button Clicked!"); contentItem: Label { text: buttonControl.text diff --git a/imports/shared/QtQuick/VirtualKeyboard/Styles/neptune/style.qml b/imports/shared/QtQuick/VirtualKeyboard/Styles/neptune/style.qml index 083e1f5..564eba9 100644 --- a/imports/shared/QtQuick/VirtualKeyboard/Styles/neptune/style.qml +++ b/imports/shared/QtQuick/VirtualKeyboard/Styles/neptune/style.qml @@ -774,7 +774,7 @@ KeyboardStyle { anchors.fill: traceInputKeyPanelBackground opacity: 0.1 onPaint: { - console.error("PAINT") + console.error(Utils.Logging.sysui, "PAINT") var ctx = getContext("2d") ctx.lineWidth = 1 ctx.strokeStyle = "#BC6608" diff --git a/imports/shared/controls/TabView.qml b/imports/shared/controls/TabView.qml index 0f0e80d..c4cd476 100644 --- a/imports/shared/controls/TabView.qml +++ b/imports/shared/controls/TabView.qml @@ -81,7 +81,7 @@ Control { clip: true Component.onCompleted: { - console.log('push initial item for tab view') + console.log(Logging.sysui, 'push initial item for tab view') push(root.tabs[root.currentIndex].url, root.tabs[root.currentIndex].properties) } diff --git a/imports/shared/controls/WebBrowser.qml b/imports/shared/controls/WebBrowser.qml index 640fad0..2681ed5 100644 --- a/imports/shared/controls/WebBrowser.qml +++ b/imports/shared/controls/WebBrowser.qml @@ -141,8 +141,8 @@ Control { onLoadingChanged: { if (loadRequest.status === WebEngineView.LoadFailedStatus) { - print("WebView.Loadfaild: " + loadRequest.errorString) - print("when loading: " + loadRequest.url) + console.log(Logging.sysui, "WebView.Loadfaild: " + loadRequest.errorString) + console.log(Logging.sysui, "when loading: " + loadRequest.url) } } } diff --git a/imports/shared/utils/AppUIScreen.qml b/imports/shared/utils/AppUIScreen.qml index f31791e..0fb724e 100644 --- a/imports/shared/utils/AppUIScreen.qml +++ b/imports/shared/utils/AppUIScreen.qml @@ -178,7 +178,6 @@ ApplicationManagerWindow { } onWindowPropertyChanged: { - //print(":::AppUIScreen::: window property changed", name, value, Qt.Key_Up) pelagicoreWindow.clusterKeyPressed(value) } } diff --git a/imports/shared/utils/Layouter.qml b/imports/shared/utils/Layouter.qml index 55bd531..6565347 100644 --- a/imports/shared/utils/Layouter.qml +++ b/imports/shared/utils/Layouter.qml @@ -58,10 +58,10 @@ Item { target.anchors.horizontalCenterOffset++ break } - console.log(target.anchors.topMargin, target.anchors.bottomMargin, - target.anchors.leftMargin, target.anchors.rightMargin, - target.anchors.verticalCenterOffset, - target.anchors.horizontalCenterOffset) + console.log(Logging.sysui, target.anchors.topMargin, target.anchors.bottomMargin, + target.anchors.leftMargin, target.anchors.rightMargin, + target.anchors.verticalCenterOffset, + target.anchors.horizontalCenterOffset) } } } diff --git a/imports/shared/utils/Logging.qml b/imports/shared/utils/Logging.qml new file mode 100644 index 0000000..4d9efc0 --- /dev/null +++ b/imports/shared/utils/Logging.qml @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Neptune IVI UI. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +pragma Singleton +import QtQuick 2.8 + +QtObject { + property bool foo: true + + property var sysui: LoggingCategory { + name: "neptune.sysui" + } + + property var apps: LoggingCategory { + name: "neptune.apps" + } +} diff --git a/imports/shared/utils/StageLoader.qml b/imports/shared/utils/StageLoader.qml index 4a24d36..96831a5 100644 --- a/imports/shared/utils/StageLoader.qml +++ b/imports/shared/utils/StageLoader.qml @@ -45,7 +45,7 @@ Loader { onStatusChanged: { if (root.status === Loader.Error) { - console.warn("Error loading component", root.source, root.sourceComponent.errorString()); + console.warn(Logging.sysui, "Error loading component", root.source, root.sourceComponent.errorString()); } } } diff --git a/imports/shared/utils/Tracer.qml b/imports/shared/utils/Tracer.qml index 500d14d..854bd0e 100644 --- a/imports/shared/utils/Tracer.qml +++ b/imports/shared/utils/Tracer.qml @@ -80,13 +80,13 @@ MouseArea { } onPressAndHold: { - console.log('trace: ' + root.parent) + console.log(Logging.sysui, 'trace: ' + root.parent) - console.log('Hierarchy: ') + console.log(Logging.sysui, 'Hierarchy: ') var parent = root.parent; var indent = ' '; while (parent) { - console.log(indent + '+ ' + parent) + console.log(Logging.sysui, indent + '+ ' + parent) indent += ' '; parent = parent.parent; } diff --git a/imports/shared/utils/qmldir b/imports/shared/utils/qmldir index a9dc749..0b9e600 100644 --- a/imports/shared/utils/qmldir +++ b/imports/shared/utils/qmldir @@ -12,3 +12,4 @@ AppUIScreen 1.0 AppUIScreen.qml NavigationUIScreen 1.0 NavigationUIScreen.qml Layouter 1.0 Layouter.qml StageLoader 1.0 StageLoader.qml +singleton Logging 1.0 Logging.qml diff --git a/imports/system/models/application/ApplicationManagerModel.qml b/imports/system/models/application/ApplicationManagerModel.qml index 33b66ce..e45a5d1 100644 --- a/imports/system/models/application/ApplicationManagerModel.qml +++ b/imports/system/models/application/ApplicationManagerModel.qml @@ -30,7 +30,7 @@ ****************************************************************************/ pragma Singleton -import QtQuick 2.0 +import QtQuick 2.8 import QtApplicationManager 1.0 import utils 1.0 @@ -53,6 +53,11 @@ QtObject { // Cluster signals signal clusterWidgetReady(string category, Item item) + property var logggingCategory: LoggingCategory { + id: logCategory + name: "neptune.applicationmanagermodel" + } + Component.onCompleted: { // Maintain a set of applications which are autostarted(preloaded) // This is needed to know that these applications should be minimized @@ -78,7 +83,7 @@ QtObject { var isMapWidget = (WindowManager.windowProperty(item, "windowType") === "widgetMap") var isClusterWidget = (WindowManager.windowProperty(item, "windowType") === "clusterWidget") - print("AMI.windowReadyHandler: index:" + index + ", item:" + item + ", map:" + console.log(logCategory, "AMI.windowReadyHandler: index:" + index + ", item:" + item + ", map:" + (isMapWidget ? "yes" : "no") + ", cluster:" + (isClusterWidget ? "yes" : "no")) var acceptWindow = true; @@ -128,7 +133,7 @@ QtObject { root.applicationSurfaceReady(item, isMinimized) } else { root.unhandledSurfaceReceived(item) - console.error("AMI.windowReadyHandler: window was not accepted: ", item) + console.error(logCategory, "AMI.windowReadyHandler: window was not accepted: ", item) } } @@ -177,7 +182,7 @@ QtObject { } function applicationActivated(appId, appAliasId) { - print("AMI.applicationActivated: appId:" + appId + ", appAliasId:" + appAliasId) + console.log(logCategory, "AMI.applicationActivated: appId:" + appId + ", appAliasId:" + appAliasId) for (var i = 0; i < WindowManager.count; i++) { if (!WindowManager.get(i).isClosing && WindowManager.get(i).applicationId === appId) { @@ -185,7 +190,7 @@ QtObject { var isMapWidget = (WindowManager.windowProperty(item, "windowType") === "widgetMap") var isClusterWidget = (WindowManager.windowProperty(item, "windowType") === "clusterWidget") - print("AMI.applicationActivated: appId:" + appId + " found item:" + item + ", map:" + console.log(logCategory, "AMI.applicationActivated: appId:" + appId + " found item:" + item + ", map:" + (isMapWidget ? "yes" : "no") + ", cluster:" + (isClusterWidget ? "yes" : "no")) if (!isMapWidget && !isClusterWidget) { diff --git a/imports/system/models/notification/NotificationModel.qml b/imports/system/models/notification/NotificationModel.qml index 8d2b2af..b8cba5c 100644 --- a/imports/system/models/notification/NotificationModel.qml +++ b/imports/system/models/notification/NotificationModel.qml @@ -30,7 +30,7 @@ ****************************************************************************/ pragma Singleton -import QtQuick 2.0 +import QtQuick 2.8 import utils 1.0 import QtApplicationManager 1.0 @@ -51,6 +51,11 @@ QtObject { property var notificationQueue:[] property var buttonModel: [] + property var logggingCategory: LoggingCategory { + id: logCategory + name: "neptune.notificationmodel" + } + property Timer notificationTimer: Timer { interval: 2000; onTriggered: { @@ -66,7 +71,7 @@ QtObject { var receivedContent = NotificationManager.notification(id); if (receivedContent.category === "notification") { - console.log("::: Notification received :::", id); + console.log(logCategory, "::: Notification received :::", id); if (!root.notificationVisible && root.notificationQueue.length === 0) { root.addNotification(id); @@ -86,7 +91,7 @@ QtObject { var receivedContent = NotificationManager.notification(id); if (receivedContent.category === "notification") { - console.log("::: Notification changed :::", id); + console.log(logCategory, "::: Notification changed :::", id); var notificationExisted = false; for (var x = 0; x < root.model.count; ++x) { diff --git a/imports/system/models/popup/PopupModel.qml b/imports/system/models/popup/PopupModel.qml index c4e0544..35e2045 100644 --- a/imports/system/models/popup/PopupModel.qml +++ b/imports/system/models/popup/PopupModel.qml @@ -30,7 +30,7 @@ ****************************************************************************/ pragma Singleton -import QtQuick 2.0 +import QtQuick 2.8 import QtApplicationManager 1.0 QtObject { @@ -53,6 +53,11 @@ QtObject { property var popupContentData property var popupButtonData + property var logggingCategory: LoggingCategory { + id: logCategory + name: "neptune.popupmodel" + } + readonly property Connections notificationManagerConnection: Connections { target: NotificationManager @@ -60,7 +65,7 @@ QtObject { var receivedContent = NotificationManager.notification(id); if (receivedContent.category === "popup") { - console.log("::: Popup received :::", id); + console.log(logCategory, "::: Popup received :::", id); if (!root.popupVisible && root.popupQueue.length === 0) { root.requestPopup(id); } @@ -80,7 +85,7 @@ QtObject { var receivedContent = NotificationManager.notification(id); if (receivedContent.category === "popup") { - console.log("::: Popup changed :::", id); + console.log(logCategory, "::: Popup changed :::", id); if (root.currentPopup.id === id) { root.processPopup(receivedContent); } else if (root.currentPopup.priority > receivedContent.priority) { diff --git a/plugins/comtqci18ndemo/comtqci18ndemo.cpp b/plugins/comtqci18ndemo/comtqci18ndemo.cpp index 33e00f1..cc4d31a 100644 --- a/plugins/comtqci18ndemo/comtqci18ndemo.cpp +++ b/plugins/comtqci18ndemo/comtqci18ndemo.cpp @@ -33,6 +33,8 @@ #include <QGuiApplication> #include <QDebug> +Q_LOGGING_CATEGORY(comTQCi18nDemo, "comtqci18ndemo") + ComTQCi18nDemo::ComTQCi18nDemo(QObject *parent) : QObject(parent) { @@ -40,21 +42,21 @@ ComTQCi18nDemo::ComTQCi18nDemo(QObject *parent) void ComTQCi18nDemo::setPrefix(const QString &languageFilePrefix) { - qDebug() << "File prefix: " << languageFilePrefix; + qCDebug(comTQCi18nDemo) << "File prefix:" << languageFilePrefix; m_languageFilePrefix = languageFilePrefix; } void ComTQCi18nDemo::setPath(const QUrl &languageFilePath) { - qDebug() << "File path: " << languageFilePath.toLocalFile(); + qCDebug(comTQCi18nDemo) << "File path:" << languageFilePath.toLocalFile(); m_languageFilePath = languageFilePath.toLocalFile(); } void ComTQCi18nDemo::setLanguageLocale(const QString &languageLocale) { - qDebug() << "Locale: " << languageLocale; + qCDebug(comTQCi18nDemo) << "Locale:" << languageLocale; if (m_languageLocale != languageLocale) { if ( loadTranslationFile(languageLocale) ) { @@ -81,16 +83,16 @@ bool ComTQCi18nDemo::loadTranslationFile(const QString &langLocale) QString fileToLoad(m_languageFilePath + m_languageFilePrefix + QLatin1Char('_')); fileToLoad += langLocale + QStringLiteral(".qm"); - qDebug() << "File to load: " << fileToLoad; + qCDebug(comTQCi18nDemo) << "File to load:" << fileToLoad; if ( m_translator.load(fileToLoad) ) { - qDebug() << "Translation file loaded"; + qCDebug(comTQCi18nDemo) << "Translation file loaded"; qApp->installTranslator(&m_translator); return true; } - qDebug() << "Failed to load translation file"; + qCDebug(comTQCi18nDemo) << "Failed to load translation file"; return false; } diff --git a/plugins/comtqci18ndemo/comtqci18ndemo.h b/plugins/comtqci18ndemo/comtqci18ndemo.h index 390e9d6..1b8e110 100644 --- a/plugins/comtqci18ndemo/comtqci18ndemo.h +++ b/plugins/comtqci18ndemo/comtqci18ndemo.h @@ -35,6 +35,9 @@ #include <QtCore/QObject> #include <QtCore/QTranslator> #include <QtCore/QUrl> +#include <QLoggingCategory> + +Q_DECLARE_LOGGING_CATEGORY(comTQCi18nDemo) class ComTQCi18nDemo : public QObject { diff --git a/plugins/datasource/datasource.pro b/plugins/datasource/datasource.pro index ad4569d..1a29747 100644 --- a/plugins/datasource/datasource.pro +++ b/plugins/datasource/datasource.pro @@ -8,6 +8,7 @@ load(qmlplugin) # Input SOURCES += \ + logging.cpp \ sqlquerydatasource.cpp \ plugin.cpp \ sqlquerymodel.cpp \ @@ -15,6 +16,7 @@ SOURCES += \ sqltabledatasource.cpp HEADERS += \ + logging.h \ sqlquerydatasource.h \ plugin.h \ sqlquerymodel.h \ diff --git a/plugins/datasource/logging.cpp b/plugins/datasource/logging.cpp new file mode 100644 index 0000000..e5322a8 --- /dev/null +++ b/plugins/datasource/logging.cpp @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Neptune IVI UI. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +#include "logging.h" + +Q_LOGGING_CATEGORY(dataSource, "datasource") diff --git a/plugins/datasource/logging.h b/plugins/datasource/logging.h new file mode 100644 index 0000000..0646d04 --- /dev/null +++ b/plugins/datasource/logging.h @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Neptune IVI UI. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +#include <QLoggingCategory> + +Q_DECLARE_LOGGING_CATEGORY(dataSource) diff --git a/plugins/datasource/sqlquerydatasource.cpp b/plugins/datasource/sqlquerydatasource.cpp index 8473373..87a72f0 100644 --- a/plugins/datasource/sqlquerydatasource.cpp +++ b/plugins/datasource/sqlquerydatasource.cpp @@ -33,6 +33,7 @@ #include <QtCore/QDebug> #include <QtSql/QSqlError> +#include "logging.h" #include "sqlquerydatasource.h" #include "sqlquerymodel.h" @@ -77,7 +78,7 @@ QString SqlQueryDataSource::query() const void SqlQueryDataSource::setQuery(const QString &queryString) { - qDebug() << "SqlQueryDataSource::setQuery() " << queryString; + qCDebug(dataSource) << "SqlQueryDataSource::setQuery()" << queryString; if (m_queryString != queryString) { m_queryString = queryString; updateModel(); @@ -107,7 +108,7 @@ void SqlQueryDataSource::updateModel() m_database = QSqlDatabase::addDatabase("QSQLITE", m_databaseName); QString databasePath = QDir(m_storageLocation).filePath(m_databaseName + ".db"); m_database.setDatabaseName(databasePath); - qDebug() << "database path: " << databasePath; + qCDebug(dataSource) << "database path:" << databasePath; } if (!m_database.isOpen()) m_database.open(); @@ -118,7 +119,7 @@ void SqlQueryDataSource::updateModel() m_model->setQuery(m_query); m_model->updateRoleNames(); if (m_query.lastError().isValid()) { - qDebug() << "Error" << m_query.lastError().text(); + qCDebug(dataSource) << "Error" << m_query.lastError().text(); setStatus(Error); } else { setStatus(Ready); diff --git a/plugins/datasource/sqltabledatasource.cpp b/plugins/datasource/sqltabledatasource.cpp index c31afd7..e7d72c6 100644 --- a/plugins/datasource/sqltabledatasource.cpp +++ b/plugins/datasource/sqltabledatasource.cpp @@ -31,6 +31,7 @@ #include "sqltabledatasource.h" #include "sqltablemodel.h" +#include "logging.h" #include <QtCore/QtDebug> #include <QtCore/QStandardPaths> @@ -95,7 +96,7 @@ void SqlTableDataSource::classBegin() void SqlTableDataSource::componentComplete() { - qDebug() << "componentComplete"; + qCDebug(dataSource) << "componentComplete"; m_componentCompleted = true; updateModel(); } @@ -107,7 +108,7 @@ QString SqlTableDataSource::storageLocation() const void SqlTableDataSource::setFilter(const QString &filter) { - qDebug() << "SqlTableDataSource::setFilter(): " << filter; + qCDebug(dataSource) << "SqlTableDataSource::setFilter(): " << filter; if (m_model && (m_model->filter() != filter)) { m_model->setFilter(filter); m_model->select(); @@ -138,27 +139,27 @@ void SqlTableDataSource::updateModel() { if (!m_componentCompleted) return; - qDebug() << "SqlTableDataSource::updateModel()"; + qCDebug(dataSource) << "SqlTableDataSource::updateModel()"; if (m_databaseName.isEmpty() || m_tableName.isEmpty()) { setStatus(Null); - qDebug() << " not configure; return"; + qCDebug(dataSource) << " not configure; return"; return; } if (!m_databaseName.isEmpty()) { if (QSqlDatabase::contains(m_databaseName)) { - qDebug() << " found existing db connection"; + qCDebug(dataSource) << " found existing db connection"; m_database = QSqlDatabase::database(m_databaseName); } else { - qDebug() << " init new db connection"; + qCDebug(dataSource) << " init new db connection"; m_database = QSqlDatabase::addDatabase("QSQLITE", m_databaseName); QString databasePath = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)).filePath(m_databaseName + ".db"); m_database.setDatabaseName(databasePath); - qDebug() << "database path: " << databasePath; + qCDebug(dataSource) << "database path: " << databasePath; } if (!m_database.isOpen()) { - qDebug() << " open database"; + qCDebug(dataSource) << " open database"; m_database.open(); - qDebug() << " tables: " << m_database.tables(); + qCDebug(dataSource) << " tables: " << m_database.tables(); } } if (m_database.isValid() && !m_tableName.isEmpty()) { @@ -171,26 +172,26 @@ void SqlTableDataSource::updateModel() m_model = new SqlTableModel(this, m_database); emit modelChanged(m_model); } - qDebug() << " update table"; + qCDebug(dataSource) << " update table"; setStatus(Loading); m_model->setTable(m_tableName); - qDebug() << " update role names"; + qCDebug(dataSource) << " update role names"; m_model->updateRoleNames(); - qDebug() << " select data"; + qCDebug(dataSource) << " select data"; if (!m_model->select()) - qDebug() << " error: select data from model"; + qCDebug(dataSource) << " error: select data from model"; while (m_model->canFetchMore()) m_model->fetchMore(QModelIndex()); - qDebug() << " finish select data"; + qCDebug(dataSource) << " finish select data"; if (m_model->lastError().isValid()) { - qDebug() << " error: " << m_model->lastError().text(); + qCDebug(dataSource) << " error: " << m_model->lastError().text(); setStatus(Error); } else { - qDebug() << " ready"; + qCDebug(dataSource) << " ready"; setStatus(Ready); } } - qDebug() << "update model: " << count(); + qCDebug(dataSource) << "update model: " << count(); emit modelChanged(m_model); emit countChanged(count()); } diff --git a/plugins/datasource/sqltablemodel.cpp b/plugins/datasource/sqltablemodel.cpp index 1d1423b..a28fbd5 100644 --- a/plugins/datasource/sqltablemodel.cpp +++ b/plugins/datasource/sqltablemodel.cpp @@ -30,6 +30,7 @@ ****************************************************************************/ #include "sqltablemodel.h" +#include "logging.h" #include <QtCore/QtDebug> #include <QtSql/QSqlRecord> @@ -44,11 +45,11 @@ SqlTableModel::SqlTableModel(QObject *parent, QSqlDatabase db) : void SqlTableModel::updateRoleNames() { - qDebug() << "SqlTableModel::updateRoleNames()"; + qCDebug(dataSource) << "SqlTableModel::updateRoleNames()"; m_roleNames.clear(); for (int i = 0; i < record().count(); i++) m_roleNames[Qt::UserRole + i + 1] = record().fieldName(i).toLatin1(); - qDebug() << " role names: " << m_roleNames.values(); + qCDebug(dataSource) << "role names:" << m_roleNames.values(); } diff --git a/plugins/styles/neptune/neptunestyleplugin.cpp b/plugins/styles/neptune/neptunestyleplugin.cpp index c60d60e..70dc19b 100644 --- a/plugins/styles/neptune/neptunestyleplugin.cpp +++ b/plugins/styles/neptune/neptunestyleplugin.cpp @@ -35,35 +35,37 @@ #include "neptunestyle.h" #include "neptunetheme.h" +Q_LOGGING_CATEGORY(neptuneStyle, "neptune.style") + NeptuneStylePlugin::NeptuneStylePlugin(QObject *parent) : QQuickStylePlugin(parent) { - qDebug() << "NeptuneStylePlugin()"; + qCDebug(neptuneStyle) << "constructor"; } void NeptuneStylePlugin::registerTypes(const char *uri) { - qDebug() << "NeptuneStylePlugin::registerTypes(): " << uri; + qCDebug(neptuneStyle) << "registerTypes():" << uri; // @uri com.pelagicore.styles.neptune qmlRegisterUncreatableType<NeptuneStyle>(uri, 1, 0, "NeptuneStyle", "NeptuneStyle is an attached property"); } void NeptuneStylePlugin::initializeEngine(QQmlEngine *engine, const char *uri) { - qDebug() << "NeptuneStylePlugin::initializeEngine()"; + qCDebug(neptuneStyle) << "initializeEngine()"; QQuickStylePlugin::initializeEngine(engine, uri); } QString NeptuneStylePlugin::name() const { - qDebug() << "NeptuneStylePlugin::name()"; + qCDebug(neptuneStyle) << "name()"; return QStringLiteral("neptune"); } QQuickProxyTheme *NeptuneStylePlugin::createTheme() const { - qDebug() << "NeptuneStylePlugin::createTheme()"; + qCDebug(neptuneStyle) << "createTheme()"; return new NeptuneTheme; } diff --git a/plugins/styles/neptune/neptunestyleplugin.h b/plugins/styles/neptune/neptunestyleplugin.h index 18e9142..6b694c9 100644 --- a/plugins/styles/neptune/neptunestyleplugin.h +++ b/plugins/styles/neptune/neptunestyleplugin.h @@ -33,8 +33,10 @@ #define NEPTUNESTYLEPLUGIN_H #include <QtQuickControls2/private/qquickstyleplugin_p.h> +#include <QLoggingCategory> QT_FORWARD_DECLARE_CLASS(QQmlEngine) +Q_DECLARE_LOGGING_CATEGORY(neptuneStyle) class NeptuneStylePlugin : public QQuickStylePlugin { diff --git a/plugins/styles/neptune/neptunetheme.cpp b/plugins/styles/neptune/neptunetheme.cpp index 68f5e8f..a0778ec 100644 --- a/plugins/styles/neptune/neptunetheme.cpp +++ b/plugins/styles/neptune/neptunetheme.cpp @@ -35,10 +35,12 @@ #include <QtGui/QFont> #include <QtGui/QFontInfo> +Q_LOGGING_CATEGORY(neptuneTheme, "neptune.theme") + NeptuneTheme::NeptuneTheme(QPlatformTheme *theme) { Q_UNUSED(theme) - qDebug() << "NeptuneTheme::NeptuneTheme()"; + qCDebug(neptuneTheme) << "constructor"; const QFont font(QLatin1String("Source Sans Pro")); if (QFontInfo(font).family() == QLatin1String("Source Sans Pro")) { const QString family = font.family(); diff --git a/plugins/styles/neptune/neptunetheme.h b/plugins/styles/neptune/neptunetheme.h index 7695a36..3ac50b7 100644 --- a/plugins/styles/neptune/neptunetheme.h +++ b/plugins/styles/neptune/neptunetheme.h @@ -34,6 +34,9 @@ #include <QtGui/QFont> #include <QtQuickControls2/private/qquickproxytheme_p.h> +#include <QLoggingCategory> + +Q_DECLARE_LOGGING_CATEGORY(neptuneTheme) class NeptuneTheme : public QQuickProxyTheme { diff --git a/styles/neptune/Switch.qml b/styles/neptune/Switch.qml index b1cc13a..72eb074 100644 --- a/styles/neptune/Switch.qml +++ b/styles/neptune/Switch.qml @@ -113,11 +113,4 @@ T.Switch { PropertyChanges { target: background; rotation: 0 } } ] - -// Tracer {} - - // Component.onCompleted: { - // console.log('Switch.qml loaded') - // Style.debugMode = false - // } } diff --git a/sysui/cloud/Store/AppStore.qml b/sysui/cloud/Store/AppStore.qml index cde9d63..6a0b598 100644 --- a/sysui/cloud/Store/AppStore.qml +++ b/sysui/cloud/Store/AppStore.qml @@ -33,6 +33,8 @@ import QtQuick 2.0 import "JSONBackend.js" as JSONBackend import QtApplicationManager 1.0 +import utils 1.0 + // TODO: Move this to a library and convert to QObject Item { @@ -51,7 +53,7 @@ Item { } function checkServer() { - print("#####################checkserver#####################") + console.log(Logging.sysui, "#####################checkserver#####################") var url = server + "/hello" var data = {"platform" : "AM", "version" : "1"} JSONBackend.setErrorFunction(function () { @@ -68,7 +70,7 @@ Item { serverOnline = false serverReason = "maintenance" } else { - print("HELLO ERROR: " + data.error) + console.log(Logging.sysui, "HELLO ERROR: " + data.error) serverOnline = false } } else { @@ -84,10 +86,10 @@ Item { JSONBackend.serverCall(url, data, function(data) { if (data !== 0) { if (data.status === "ok") { - print("LOGIN SUCCESSFUL"); + console.log(Logging.sysui, "LOGIN SUCCESSFUL"); loginSuccessful() } else { - print("LOGIN ERROR: " + data.error) + console.log(Logging.sysui, "LOGIN ERROR: " + data.error) } } }) diff --git a/sysui/cloud/Store/AppStoreController.qml b/sysui/cloud/Store/AppStoreController.qml index 1888816..eaf212d 100644 --- a/sysui/cloud/Store/AppStoreController.qml +++ b/sysui/cloud/Store/AppStoreController.qml @@ -55,14 +55,14 @@ Item { JSONBackend.serverCall(url, data, function(data) { if (data !== 0) { if (data.status === "ok") { - print("start downloading") + console.log(Logging.sysui, "start downloading") var icon = appstore.server + "/app/icon?id=" + id var installID = ApplicationInstaller.startPackageInstallation("internal-0", data.url); ApplicationInstaller.acknowledgePackageInstallation(installID); } else if (data.status === "fail" && data.error === "not-logged-in"){ - print(":::AppStoreController::: not logged in") + console.log(Logging.sysui, ":::AppStoreController::: not logged in") } else { - print(":::AppStoreController::: download failed: " + data.error) + console.log(Logging.sysui, ":::AppStoreController::: download failed: " + data.error) } } }) diff --git a/sysui/cloud/Store/JSONBackend.js b/sysui/cloud/Store/JSONBackend.js index f4d7936..e48f149 100644 --- a/sysui/cloud/Store/JSONBackend.js +++ b/sysui/cloud/Store/JSONBackend.js @@ -57,21 +57,20 @@ function serverCall(url, data, dataReadyFunction, xhr) { xhr = new XMLHttpRequest() } - console.log("HTTP GET to " + url); + console.log(Logging.sysui, "HTTP GET to " + url); if (xhr.readyState != 0) { xhr.abort(); } xhr.open("GET", url); xhr.onreadystatechange = function() { if (xhr.readyState == XMLHttpRequest.DONE) { - //print(xhr.responseText); if (xhr.responseText !== "") { errorCounter = 0 var data = JSON.parse(xhr.responseText); return dataReadyFunction(data) } else { - print("JSONBackend: " + xhr.status + xhr.statusText) + console.log(Logging.sysui, "JSONBackend: " + xhr.status + xhr.statusText) errorCounter++ if (errorCounter >= 3 && errorFunc) { errorFunc() diff --git a/sysui/display/LauncherPage.qml b/sysui/display/LauncherPage.qml index c950176..57456f1 100644 --- a/sysui/display/LauncherPage.qml +++ b/sysui/display/LauncherPage.qml @@ -104,13 +104,13 @@ UIPage { view.editMode = false } else { if (!model.isUpdating) { - console.log("Starting app " + model.applicationId + ": " + ApplicationManager.startApplication(model.applicationId)); + console.log(Logging.sysui, "Starting app " + model.applicationId + ": " + ApplicationManager.startApplication(model.applicationId)); } } } onRemoveClicked: { - console.log('003: remove app') + console.log(Logging.sysui, '003: remove app') view.editMode = false; ApplicationInstaller.removePackage(model.applicationId, false /*keepDocuments*/, true /*force*/); } |