on xenial help sign in
convert to categorized logging
5d1de82Lukáš Tinkl
plugins/Ubuntu/SystemImage/SystemImage.cpp+14−9
@@ -27,6 +27,11 @@
27#define SYSTEMIMAGE_PATH QStringLiteral("/Service")
27#define SYSTEMIMAGE_PATH QStringLiteral("/Service")
28#define SYSTEMIMAGE_IFACE QStringLiteral("com.canonical.SystemImage")
28#define SYSTEMIMAGE_IFACE QStringLiteral("com.canonical.SystemImage")
29
29
30+Q_LOGGING_CATEGORY(SYSTEMIMAGEPLUGIN, "unity8.systemimage", QtWarningMsg)
31+
32+#define DEBUG_MSG qCDebug(SYSTEMIMAGEPLUGIN).nospace().noquote() << Q_FUNC_INFO
33+#define WARNING_MSG qCWarning(SYSTEMIMAGEPLUGIN).nospace().noquote() << Q_FUNC_INFO
34+
30SystemImage::SystemImage(QObject *parent)
35SystemImage::SystemImage(QObject *parent)
31 : QObject(parent)
36 : QObject(parent)
32{
37{
@@ -44,7 +49,7 @@ SystemImage::SystemImage(QObject *parent)
44
49
45void SystemImage::checkForUpdate()
50void SystemImage::checkForUpdate()
46{
51{
47− qDebug() << "!!! Checking for update";
52+ DEBUG_MSG << "Checking for update";
48 const QDBusMessage msg = QDBusMessage::createMethodCall(SYSTEMIMAGE_SERVICE, SYSTEMIMAGE_PATH, SYSTEMIMAGE_IFACE,
53 const QDBusMessage msg = QDBusMessage::createMethodCall(SYSTEMIMAGE_SERVICE, SYSTEMIMAGE_PATH, SYSTEMIMAGE_IFACE,
49 QStringLiteral("CheckForUpdate"));
54 QStringLiteral("CheckForUpdate"));
50 QDBusConnection::systemBus().asyncCall(msg);
55 QDBusConnection::systemBus().asyncCall(msg);
@@ -52,7 +57,7 @@ void SystemImage::checkForUpdate()
52
57
53void SystemImage::applyUpdate()
58void SystemImage::applyUpdate()
54{
59{
55− qDebug() << "!!! Applying update";
60+ DEBUG_MSG << "Applying update";
56 setUpdateApplying(true);
61 setUpdateApplying(true);
57
62
58 const QDBusMessage msg = QDBusMessage::createMethodCall(SYSTEMIMAGE_SERVICE, SYSTEMIMAGE_PATH, SYSTEMIMAGE_IFACE,
63 const QDBusMessage msg = QDBusMessage::createMethodCall(SYSTEMIMAGE_SERVICE, SYSTEMIMAGE_PATH, SYSTEMIMAGE_IFACE,
@@ -70,7 +75,7 @@ void SystemImage::factoryReset()
70void SystemImage::onUpdateAvailableStatus(bool is_available, bool downloading, const QString &available_version, int update_size,
75void SystemImage::onUpdateAvailableStatus(bool is_available, bool downloading, const QString &available_version, int update_size,
71 const QString &last_update_date, const QString &error_reason)
76 const QString &last_update_date, const QString &error_reason)
72{
77{
73− qDebug() << Q_FUNC_INFO << "A new update is" << (is_available ? "" : "NOT") << "available";
78+ DEBUG_MSG << "A new update is " << (is_available ? "" : "NOT") << "available";
74
79
75 if (is_available == m_updateAvailable) {
80 if (is_available == m_updateAvailable) {
76 return;
81 return;
@@ -84,13 +89,13 @@ void SystemImage::onUpdateAvailableStatus(bool is_available, bool downloading, c
84 m_errorReason = error_reason;
89 m_errorReason = error_reason;
85 Q_EMIT updateAvailableStatus();
90 Q_EMIT updateAvailableStatus();
86
91
87− qDebug() << "!!! Downloading:" << downloading << ", version:" << available_version << ", last update:" << last_update_date <<
92+ DEBUG_MSG << "Downloading: " << downloading << ", version: " << available_version << ", last update: " << last_update_date <<
88− ", size:" << m_updateSize;
93+ ", size: " << m_updateSize;
89}
94}
90
95
91void SystemImage::onUpdateDownloaded()
96void SystemImage::onUpdateDownloaded()
92{
97{
93− qDebug() << "!!! Update downloaded";
98+ DEBUG_MSG << "Update downloaded";
94
99
95 m_downloaded = true;
100 m_downloaded = true;
96 Q_EMIT updateDownloadedChanged();
101 Q_EMIT updateDownloadedChanged();
@@ -98,13 +103,13 @@ void SystemImage::onUpdateDownloaded()
98
103
99void SystemImage::onUpdateFailed(int /*consecutive_failure_count*/, const QString &last_reason)
104void SystemImage::onUpdateFailed(int /*consecutive_failure_count*/, const QString &last_reason)
100{
105{
101− qWarning() << Q_FUNC_INFO << "System Update failed:" << last_reason;
106+ WARNING_MSG << "System Update failed: " << last_reason;
102 setUpdateApplying(false);
107 setUpdateApplying(false);
103}
108}
104
109
105void SystemImage::onUpdateApplied(bool applied)
110void SystemImage::onUpdateApplied(bool applied)
106{
111{
107− qDebug() << Q_FUNC_INFO << "System Update applied with status:" << applied;
112+ DEBUG_MSG << "System Update applied with status: " << applied;
108 setUpdateApplying(false);
113 setUpdateApplying(false);
109 if (applied) {
114 if (applied) {
110 resetUpdateStatus();
115 resetUpdateStatus();
@@ -115,7 +120,7 @@ void SystemImage::onUpdateApplied(bool applied)
115void SystemImage::onRebooting(bool status)
120void SystemImage::onRebooting(bool status)
116{
121{
117 setUpdateApplying(false);
122 setUpdateApplying(false);
118− qDebug() << "!!! Rebooting:" << status;
123+ DEBUG_MSG << "Rebooting: " << status;
119}
124}
120
125
121void SystemImage::setUpdateApplying(bool status)
126void SystemImage::setUpdateApplying(bool status)
plugins/Ubuntu/SystemImage/SystemImage.h+3
@@ -18,6 +18,9 @@
18#define SYSTEMIMAGE_H
18#define SYSTEMIMAGE_H
19
19
20#include <QObject>
20#include <QObject>
21+#include <QLoggingCategory>
22+
23+Q_DECLARE_LOGGING_CATEGORY(SYSTEMIMAGEPLUGIN)
21
24
22class SystemImage : public QObject
25class SystemImage : public QObject
23{
26{