Merge lp:~online-accounts/accounts-qml-module/packaging into lp:accounts-qml-module

Proposed by Alberto Mardegan
Status: Merged
Approved by: David Barth
Approved revision: no longer in the source branch.
Merged at revision: 61
Proposed branch: lp:~online-accounts/accounts-qml-module/packaging
Merge into: lp:accounts-qml-module
Diff against target: 130 lines (+64/-7)
5 files modified
debian/changelog (+7/-0)
src/debug.cpp (+29/-0)
src/debug.h (+21/-6)
src/plugin.cpp (+6/-1)
src/src.pro (+1/-0)
To merge this branch: bzr merge lp:~online-accounts/accounts-qml-module/packaging
Reviewer Review Type Date Requested Status
Online Accounts Pending
Review via email: mp+276621@code.launchpad.net

Commit message

Hide debug messages by default

Introduce a OAQ_LOGGING_LEVEL variable which can be set to 2 in order to
enable debug messages (or to 0 to hide warnings too).

Description of the change

Hide debug messages by default

Introduce a OAQ_LOGGING_LEVEL variable which can be set to 2 in order to
enable debug messages (or to 0 to hide warnings too).

To post a comment you must log in.
61. By Alberto Mardegan

Hide debug messages by default

Introduce a OAQ_LOGGING_LEVEL variable which can be set to 2 in order to
enable debug messages (or to 0 to hide warnings too).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2015-10-28 15:59:00 +0000
3+++ debian/changelog 2015-11-04 07:30:22 +0000
4@@ -1,3 +1,10 @@
5+accounts-qml-module (0.6+16.04.20151028-0ubuntu3) UNRELEASED; urgency=medium
6+
7+ * Merge from upstream:
8+ - Hide debug messages by default (LP: #1404267)
9+
10+ -- Alberto Mardegan <alberto.mardegan@canonical.com> Wed, 04 Nov 2015 10:15:57 +0300
11+
12 accounts-qml-module (0.6+16.04.20151028-0ubuntu1) xenial; urgency=medium
13
14 [ Alberto Mardegan ]
15
16=== added file 'src/debug.cpp'
17--- src/debug.cpp 1970-01-01 00:00:00 +0000
18+++ src/debug.cpp 2015-11-04 07:30:22 +0000
19@@ -0,0 +1,29 @@
20+/*
21+ * Copyright (C) 2015 Canonical Ltd.
22+ *
23+ * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
24+ *
25+ * This program is free software; you can redistribute it and/or modify
26+ * it under the terms of the GNU Lesser General Public License as published by
27+ * the Free Software Foundation; version 2.1.
28+ *
29+ * This program is distributed in the hope that it will be useful,
30+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
31+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32+ * GNU Lesser General Public License for more details.
33+ *
34+ * You should have received a copy of the GNU Lesser General Public License
35+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
36+ */
37+
38+#include "debug.h"
39+
40+int accounts_qml_module_logging_level = 1;
41+
42+namespace OnlineAccounts {
43+
44+void setLoggingLevel(int level) {
45+ accounts_qml_module_logging_level = level;
46+}
47+
48+}
49
50=== modified file 'src/debug.h'
51--- src/debug.h 2013-05-31 06:46:13 +0000
52+++ src/debug.h 2015-11-04 07:30:22 +0000
53@@ -1,5 +1,5 @@
54 /*
55- * Copyright (C) 2013 Canonical Ltd.
56+ * Copyright (C) 2013-2015 Canonical Ltd.
57 *
58 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
59 *
60@@ -22,13 +22,28 @@
61 #include <QDebug>
62
63 #ifdef DEBUG_ENABLED
64- #define DEBUG() \
65- qDebug() << __FILE__ << __LINE__ << __func__
66- #define WARNING() \
67- qCritical() << __FILE__ << __LINE__ << __func__
68-#else
69+extern int accounts_qml_module_logging_level;
70+static inline bool debugEnabled() {
71+ return accounts_qml_module_logging_level >= 2;
72+}
73+
74+static inline bool criticalsEnabled() {
75+ return accounts_qml_module_logging_level >= 1;
76+}
77+#define DEBUG() \
78+ if (debugEnabled()) qDebug()
79+#define BLAME() \
80+ if (criticalsEnabled()) qCritical()
81+
82+#else // DEBUG_ENABLED
83 #define DEBUG() while (0) qDebug()
84 #define WARNING() while (0) qDebug()
85 #endif
86
87+namespace OnlineAccounts {
88+
89+void setLoggingLevel(int level);
90+
91+}
92+
93 #endif // ONLINE_ACCOUNTS_DEBUG_H
94
95=== modified file 'src/plugin.cpp'
96--- src/plugin.cpp 2013-06-13 07:44:44 +0000
97+++ src/plugin.cpp 2015-11-04 07:30:22 +0000
98@@ -21,6 +21,7 @@
99 #include "account.h"
100 #include "application-model.h"
101 #include "credentials.h"
102+#include "debug.h"
103 #include "manager.h"
104 #include "plugin.h"
105 #include "provider-model.h"
106@@ -40,7 +41,11 @@
107
108 void Plugin::registerTypes(const char *uri)
109 {
110- qDebug() << Q_FUNC_INFO << uri;
111+ QByteArray loggingLevelVar = qgetenv("OAQ_LOGGING_LEVEL");
112+ if (!loggingLevelVar.isEmpty()) {
113+ setLoggingLevel(loggingLevelVar.toInt());
114+ }
115+ DEBUG() << Q_FUNC_INFO << uri;
116 qmlRegisterType<AccountServiceModel>(uri, 0, 1, "AccountServiceModel");
117 qmlRegisterType<AccountService>(uri, 0, 1, "AccountService");
118 qmlRegisterType<Account>(uri, 0, 1, "Account");
119
120=== modified file 'src/src.pro'
121--- src/src.pro 2013-10-09 09:23:13 +0000
122+++ src/src.pro 2015-11-04 07:30:22 +0000
123@@ -33,6 +33,7 @@
124 application-model.cpp \
125 application.cpp \
126 credentials.cpp \
127+ debug.cpp \
128 manager.cpp \
129 plugin.cpp \
130 provider-model.cpp

Subscribers

People subscribed via source and target branches

to all changes: