Merge lp:~pete-woods/indicator-network/improve-logging into lp:indicator-network

Proposed by Pete Woods
Status: Merged
Approved by: Pete Woods
Approved revision: 598
Merged at revision: 600
Proposed branch: lp:~pete-woods/indicator-network/improve-logging
Merge into: lp:indicator-network
Prerequisite: lp:~unity-api-team/indicator-network/connectivity-api-mobile-data-management
Diff against target: 935 lines (+213/-70)
25 files modified
src/agent/KeyringCredentialStore.cpp (+2/-2)
src/agent/SecretAgent.cpp (+8/-8)
src/agent/agent-main.cpp (+3/-0)
src/indicator/main.cpp (+4/-0)
src/indicator/nmofono/connection/active-connection-manager.cpp (+1/-1)
src/indicator/nmofono/hotspot-manager.cpp (+12/-12)
src/indicator/nmofono/kill-switch.cpp (+3/-3)
src/indicator/nmofono/manager-impl.cpp (+22/-17)
src/indicator/nmofono/vpn/vpn-connection.cpp (+3/-3)
src/indicator/nmofono/vpn/vpn-manager.cpp (+1/-1)
src/indicator/nmofono/wifi/wifi-link-impl.cpp (+9/-4)
src/indicator/nmofono/wwan/modem.cpp (+6/-2)
src/indicator/root-state.cpp (+1/-1)
src/indicator/vpn-status-notifier.cpp (+1/-1)
src/menumodel-cpp/action-group-merger.cpp (+3/-3)
src/menumodel-cpp/menu-item.cpp (+1/-1)
src/notify-cpp/notification.cpp (+4/-4)
src/qpowerd/qpowerd.cpp (+1/-1)
src/util/CMakeLists.txt (+1/-0)
src/util/logging.cpp (+59/-0)
src/util/logging.h (+29/-0)
tests/unit/secret-agent/secret-agent-main.cpp (+29/-1)
tests/unit/secret-agent/test-secret-agent.cpp (+3/-3)
tests/utils/CMakeLists.txt (+3/-2)
tests/utils/main.cpp (+4/-0)
To merge this branch: bzr merge lp:~pete-woods/indicator-network/improve-logging
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
Antti Kaijanmäki Pending
PS Jenkins bot continuous-integration Pending
Review via email: mp+295828@code.launchpad.net

This proposal supersedes a proposal from 2016-05-25.

Commit message

Improve logging

Description of the change

Improve logging

To post a comment you must log in.
Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote : Posted in a previous version of this proposal

LGTM.

review: Approve
Revision history for this message
Charles Kerr (charlesk) wrote :

Oh, I'm stealing this.

review: Approve
Revision history for this message
Charles Kerr (charlesk) wrote :

Not a showstopper, but a minor nit this does kick up one new warning when I build:

src/util/logging.cpp: In function ‘void util::loggingFunction(QtMsgType, const QMessageLogContext&, const QString&)’:
src/util/logging.cpp:28:16: warning: switch missing default case [-Wswitch-default]

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/agent/KeyringCredentialStore.cpp'
2--- src/agent/KeyringCredentialStore.cpp 2016-02-18 12:37:05 +0000
3+++ src/agent/KeyringCredentialStore.cpp 2016-05-26 16:58:27 +0000
4@@ -80,7 +80,7 @@
5 }
6 g_error_free(error);
7 }
8- qCritical() << __PRETTY_FUNCTION__ << message;
9+ qCritical() << message;
10 }
11 }
12
13@@ -146,7 +146,7 @@
14 message = QString::fromUtf8(error->message);
15 }
16 g_error_free(error);
17- qCritical() << __PRETTY_FUNCTION__ << message;
18+ qCritical() << message;
19 }
20 }
21 }
22
23=== modified file 'src/agent/SecretAgent.cpp'
24--- src/agent/SecretAgent.cpp 2016-02-18 12:37:30 +0000
25+++ src/agent/SecretAgent.cpp 2016-05-26 16:58:27 +0000
26@@ -132,7 +132,7 @@
27 NM_SECRET_AGENT_CAPABILITY_NONE);
28 reply.waitForFinished();
29 if (reply.isError()) {
30- qCritical() << __PRETTY_FUNCTION__ << reply.error().message();
31+ qCritical() << reply.error().message();
32 }
33 }
34 }
35@@ -176,7 +176,7 @@
36 NM_SECRET_AGENT_CAPABILITY_NONE);
37 reply.waitForFinished();
38 if (reply.isError()) {
39- qCritical() << __PRETTY_FUNCTION__ << reply.error().message();
40+ qCritical() << reply.error().message();
41 }
42 }
43
44@@ -184,7 +184,7 @@
45 auto reply = d->m_agentManager.Unregister();
46 reply.waitForFinished();
47 if (reply.isError()) {
48- qCritical() << __PRETTY_FUNCTION__ << reply.error().message();
49+ qCritical() << reply.error().message();
50 }
51 }
52
53@@ -232,7 +232,7 @@
54
55 setDelayedReply(true);
56
57- qDebug() << __PRETTY_FUNCTION__ << connectionPath.path() << settingName << hints << flags;
58+ qDebug() << connectionPath.path() << settingName << hints << flags;
59
60 // If we want a WiFi secret, and
61 if (settingName == NM_WIRELESS_SECURITY_SETTING_NAME &&
62@@ -241,12 +241,12 @@
63 ((flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW) > 0) ||
64 ((flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED) > 0)
65 )) {
66- qDebug() << __PRETTY_FUNCTION__ << "Requesting secret from user";
67+ qDebug() << "Requesting secret from user";
68 d->m_request.reset(new SecretRequest(*this, connection,
69 connectionPath, settingName, hints, flags, message()));
70 } else if (((flags == NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE) ||
71 (flags == NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED))) {
72- qDebug() << __PRETTY_FUNCTION__ << "Retrieving secret from keyring";
73+ qDebug() << "Retrieving secret from keyring";
74
75 bool isVpn = (settingName == NM_VPN_SETTING_NAME);
76
77@@ -288,7 +288,7 @@
78 d->m_systemConnection.send(
79 message().createReply(QVariant::fromValue(newConnection)));
80 } else {
81- qDebug() << __PRETTY_FUNCTION__ << "Can't get secrets for this connection";
82+ qDebug() << "Can't get secrets for this connection";
83 d->m_systemConnection.send(
84 message().createErrorReply("org.freedesktop.NetworkManager.SecretAgent.NoSecrets",
85 "No secrets found for this connection."));
86@@ -301,7 +301,7 @@
87 if (error) {
88 d->m_systemConnection.send(
89 request.message().createErrorReply("org.freedesktop.NetworkManager.SecretAgent.NoSecrets",
90- "No password found for this connection."));
91+ "No secrets found for this connection."));
92 } else {
93 d->m_systemConnection.send(
94 request.message().createReply(
95
96=== modified file 'src/agent/agent-main.cpp'
97--- src/agent/agent-main.cpp 2016-02-15 09:31:38 +0000
98+++ src/agent/agent-main.cpp 2016-05-26 16:58:27 +0000
99@@ -20,6 +20,7 @@
100 #include <notify-cpp/notification-manager.h>
101 #include <agent/KeyringCredentialStore.h>
102 #include <agent/SecretAgent.h>
103+#include <util/logging.h>
104 #include <util/unix-signal-handler.h>
105 #include <dbus-types.h>
106
107@@ -38,6 +39,8 @@
108 int
109 main(int argc, char **argv)
110 {
111+ qInstallMessageHandler(util::loggingFunction);
112+
113 QCoreApplication app(argc, argv);
114 DBusTypes::registerMetaTypes();
115 Variant::registerMetaTypes();
116
117=== modified file 'src/indicator/main.cpp'
118--- src/indicator/main.cpp 2015-12-11 14:58:11 +0000
119+++ src/indicator/main.cpp 2016-05-26 16:58:27 +0000
120@@ -18,6 +18,7 @@
121 */
122
123 #include <factory.h>
124+#include <util/logging.h>
125 #include <util/unix-signal-handler.h>
126 #include <dbus-types.h>
127
128@@ -34,9 +35,12 @@
129 using namespace std;
130 using namespace connectivity_service;
131
132+
133 int
134 main(int argc, char **argv)
135 {
136+ qInstallMessageHandler(util::loggingFunction);
137+
138 QCoreApplication app(argc, argv);
139 DBusTypes::registerMetaTypes();
140 Variant::registerMetaTypes();
141
142=== modified file 'src/indicator/nmofono/connection/active-connection-manager.cpp'
143--- src/indicator/nmofono/connection/active-connection-manager.cpp 2015-10-06 10:19:30 +0000
144+++ src/indicator/nmofono/connection/active-connection-manager.cpp 2016-05-26 16:58:27 +0000
145@@ -115,7 +115,7 @@
146 reply.waitForFinished();
147 if (reply.isError())
148 {
149- qWarning() << __PRETTY_FUNCTION__ << reply.error().message();
150+ qWarning() << reply.error().message();
151 return false;
152 }
153 return true;
154
155=== modified file 'src/indicator/nmofono/hotspot-manager.cpp'
156--- src/indicator/nmofono/hotspot-manager.cpp 2016-05-11 16:52:45 +0000
157+++ src/indicator/nmofono/hotspot-manager.cpp 2016-05-26 16:58:27 +0000
158@@ -62,7 +62,7 @@
159
160 void addConnection()
161 {
162- qDebug() << __PRETTY_FUNCTION__ << "Adding new hotspot connection";
163+ qDebug() << "Adding new hotspot connection";
164 QVariantDictMap connection = createConnectionSettings(m_ssid, m_password,
165 m_mode, m_auth);
166
167@@ -91,7 +91,7 @@
168
169 void updateConnection()
170 {
171- qDebug() << __PRETTY_FUNCTION__ << "Updating hotspot connection";
172+ qDebug() << "Updating hotspot connection";
173 // Get new settings
174 QVariantDictMap new_settings = createConnectionSettings(m_ssid,
175 m_password,
176@@ -129,7 +129,7 @@
177 // Wait for connection to activate
178 while (count < 20 && activeConnection.state() != NM_ACTIVE_CONNECTION_STATE_ACTIVATED)
179 {
180- qDebug() << __PRETTY_FUNCTION__ << "Waiting for hotspot to connect";
181+ qDebug() << "Waiting for hotspot to connect";
182 QThread::msleep(100);
183 ++count;
184 }
185@@ -144,11 +144,11 @@
186 {
187 if (!m_hotspot)
188 {
189- qWarning() << __PRETTY_FUNCTION__ << "Could not find a hotspot setup to enable";
190+ qWarning() << "Could not find a hotspot setup to enable";
191 return;
192 }
193
194- qDebug() << __PRETTY_FUNCTION__ << "Activating hotspot on device" << device.path();
195+ qDebug() << "Activating hotspot on device" << device.path();
196 bool success = activateConnection(device);
197 setEnable(success);
198 if (success)
199@@ -332,7 +332,7 @@
200 continue;
201 }
202
203- qDebug() << __PRETTY_FUNCTION__ << "Using AP interface " << interface;
204+ qDebug() << "Using AP interface " << interface;
205 m_device = make_unique<ApDevice>(*path, interface);
206 break;
207 }
208@@ -350,7 +350,7 @@
209 {
210 QThread::msleep(100);
211 findApDevice();
212- qDebug() << __PRETTY_FUNCTION__ << "Searching for AP device";
213+ qDebug() << "Searching for AP device";
214 ++count;
215 }
216 }
217@@ -546,7 +546,7 @@
218 {
219 if (!m_hotspot)
220 {
221- qWarning() << __PRETTY_FUNCTION__ << "Could not find a hotspot setup to enable";
222+ qWarning() << "Could not find a hotspot setup to enable";
223 return;
224 }
225
226@@ -561,12 +561,12 @@
227
228 if (m_device)
229 {
230- qDebug() << __PRETTY_FUNCTION__ << "Reactivating hotspot connection on device" << m_device->m_path.path();
231+ qDebug() << "Reactivating hotspot connection on device" << m_device->m_path.path();
232 activateConnection(m_device->m_path);
233 }
234 else
235 {
236- qWarning() << __PRETTY_FUNCTION__ << "Could not get device when reactivating hotspot connection";
237+ qWarning() << "Could not get device when reactivating hotspot connection";
238 }
239 }
240
241@@ -649,7 +649,7 @@
242 // If the SSID is empty, we report an error.
243 if (d->m_ssid.isEmpty())
244 {
245- qWarning() << __PRETTY_FUNCTION__ << " SSID was empty";
246+ qWarning() << " SSID was empty";
247 Q_EMIT reportError(1);
248 d->setEnable(false);
249 return;
250@@ -662,7 +662,7 @@
251
252 if (!d->m_device)
253 {
254- qWarning() << __PRETTY_FUNCTION__ << "Failed to create AP device";
255+ qWarning() << "Failed to create AP device";
256 Q_EMIT reportError(1);
257 d->setDisconnectWifi(false);
258 return;
259
260=== modified file 'src/indicator/nmofono/kill-switch.cpp'
261--- src/indicator/nmofono/kill-switch.cpp 2015-08-06 11:23:00 +0000
262+++ src/indicator/nmofono/kill-switch.cpp 2016-05-26 16:58:27 +0000
263@@ -118,7 +118,7 @@
264 {
265 if (!block && state() == State::hard_blocked)
266 {
267- qCritical() << __PRETTY_FUNCTION__ << "Killswitch is hard blocked.";
268+ qCritical() << "Killswitch is hard blocked.";
269 return;
270 }
271
272@@ -141,7 +141,7 @@
273 }
274 catch (std::exception &e)
275 {
276- qCritical() << __PRETTY_FUNCTION__ << e.what();
277+ qCritical() << e.what();
278 }
279 }
280
281@@ -163,7 +163,7 @@
282 }
283 catch (std::runtime_error& e)
284 {
285- qWarning() << __PRETTY_FUNCTION__ << ": " << QString::fromStdString(e.what());
286+ qWarning() << e.what();
287 return false;
288 }
289 }
290
291=== modified file 'src/indicator/nmofono/manager-impl.cpp'
292--- src/indicator/nmofono/manager-impl.cpp 2016-05-26 16:58:27 +0000
293+++ src/indicator/nmofono/manager-impl.cpp 2016-05-26 16:58:27 +0000
294@@ -288,6 +288,9 @@
295 auto toAdd = modemPaths;
296 toAdd.subtract(currentModemPaths);
297
298+ if (!toRemove.isEmpty()) {
299+ qDebug() << "Removing modems" << toRemove;
300+ }
301 for (const auto& path : toRemove)
302 {
303 auto modem = m_ofonoLinks.take(path);
304@@ -301,6 +304,9 @@
305 Q_EMIT p.modemsChanged();
306 }
307
308+ if (!toAdd.isEmpty()) {
309+ qDebug() << "Adding modems" << toAdd;
310+ }
311 for (const auto& path : toAdd)
312 {
313 auto modemInterface = make_shared<QOfonoModem>();
314@@ -467,6 +473,8 @@
315 void
316 ManagerImpl::setWifiEnabled(bool enabled)
317 {
318+ qDebug() << "Setting WiFi enabled =" << enabled;
319+
320 if (!d->m_hasWifi)
321 {
322 return;
323@@ -504,6 +512,8 @@
324 void
325 ManagerImpl::setHotspotEnabled(bool enabled)
326 {
327+ qDebug() << "Setting hotspot enabled =" << enabled;
328+
329 if (d->m_hotspotManager->enabled() == enabled)
330 {
331 return;
332@@ -511,7 +521,7 @@
333
334 if (enabled && d->m_flightMode)
335 {
336- qWarning() << __PRETTY_FUNCTION__ << "Cannot set hotspot enabled when flight mode is on";
337+ qWarning() << "Cannot set hotspot enabled when flight mode is on";
338 return;
339 }
340
341@@ -530,6 +540,8 @@
342 void
343 ManagerImpl::setFlightMode(bool enabled)
344 {
345+ qDebug() << "Setting flight mode enabled =" << enabled;
346+
347 if (enabled == d->m_killSwitch->isFlightMode())
348 {
349 return;
350@@ -567,9 +579,7 @@
351 void
352 ManagerImpl::device_removed(const QDBusObjectPath &path)
353 {
354-#ifdef INDICATOR_NETWORK_TRACE_MESSAGES
355- qDebug() << "Device Removed:" << path.path();
356-#endif
357+ qDebug() << "Device Removed:" << path.path();
358 Link::Ptr toRemove;
359 for (auto dev : d->m_nmLinks)
360 {
361@@ -591,9 +601,7 @@
362 void
363 ManagerImpl::device_added(const QDBusObjectPath &path)
364 {
365-#ifdef INDICATOR_NETWORK_TRACE_MESSAGES
366 qDebug() << "Device Added:" << path.path();
367-#endif
368 for (const auto &dev : d->m_nmLinks)
369 {
370 auto wifiLink = dynamic_pointer_cast<wifi::WifiLinkImpl>(dev);
371@@ -623,7 +631,7 @@
372 }
373 }
374 } catch (const exception &e) {
375- qDebug() << __PRETTY_FUNCTION__ << ": failed to create Device proxy for "<< path.path() << ": ";
376+ qDebug() << ": failed to create Device proxy for "<< path.path() << ": ";
377 qDebug() << "\t" << e.what();
378 qDebug() << "\tIgnoring.";
379 return;
380@@ -694,6 +702,7 @@
381 || d->m_unlockDialog->modem() == modem
382 || count(d->m_pendingUnlocks.begin(), d->m_pendingUnlocks.end(), modem) != 0)
383 {
384+ qDebug() << "Didn't unlock modem because it's already being unlocked or is queued for unlock" << modem->simIdentifier();
385 return;
386 }
387
388@@ -702,15 +711,18 @@
389 {
390 if (modem->isReadyToUnlock())
391 {
392+ qDebug() << "Unlocking modem" << modem->simIdentifier();
393 d->m_unlockDialog->unlock(modem);
394 }
395 else
396 {
397+ qDebug() << "Waiting for modem to be ready" << modem->simIdentifier();
398 modem->notifyWhenReadyToUnlock();
399 }
400 }
401 else
402 {
403+ qDebug() << "Queueing modem for unlock" << modem->simIdentifier();
404 d->m_pendingUnlocks.push_back(modem);
405 }
406 } catch(const exception &e) {
407@@ -718,21 +730,16 @@
408 // crashed taking the notification server with it. There is no graceful
409 // and reliable way to recover so die and get restarted.
410 // See also https://bugs.launchpad.net/unity-notifications/+bug/1238990
411- qWarning() << __PRETTY_FUNCTION__ << " sim unlocking failed: " << QString::fromStdString(e.what());
412+ qWarning() << " sim unlocking failed: " << QString::fromStdString(e.what());
413 }
414 }
415
416 void
417 ManagerImpl::unlockAllModems()
418 {
419-#ifdef INDICATOR_NETWORK_TRACE_MESSAGES
420- qDebug() << __PRETTY_FUNCTION__;
421-#endif
422+ qDebug() << "Unlock all modems";
423 for (auto& m : d->m_ofonoLinks)
424 {
425-#ifdef INDICATOR_NETWORK_TRACE_MESSAGES
426- qDebug() << "Unlocking " << m->simIdentifier();
427-#endif
428 unlockModem(m);
429 }
430 }
431@@ -740,9 +747,7 @@
432 void
433 ManagerImpl::unlockModemByName(const QString &name)
434 {
435-#ifdef INDICATOR_NETWORK_TRACE_MESSAGES
436- qDebug() << __PRETTY_FUNCTION__ ;
437-#endif
438+ qDebug() << "Unlock modem:" << name;
439 auto it = d->m_ofonoLinks.find(name);
440 if (it != d->m_ofonoLinks.cend())
441 {
442
443=== modified file 'src/indicator/nmofono/vpn/vpn-connection.cpp'
444--- src/indicator/nmofono/vpn/vpn-connection.cpp 2016-03-04 11:03:02 +0000
445+++ src/indicator/nmofono/vpn/vpn-connection.cpp 2016-05-26 16:58:27 +0000
446@@ -206,7 +206,7 @@
447 reply.waitForFinished();
448 if (reply.isError())
449 {
450- qWarning() << __PRETTY_FUNCTION__ << reply.error().message() << m_pendingSettings;
451+ qWarning() << reply.error().message() << m_pendingSettings;
452 }
453
454 m_dirty = false;
455@@ -237,7 +237,7 @@
456 reply.waitForFinished();
457 if (reply.isError())
458 {
459- qWarning() << __PRETTY_FUNCTION__ << reply.error().message();
460+ qWarning() << reply.error().message();
461 return;
462 }
463
464@@ -261,7 +261,7 @@
465 reply.waitForFinished();
466 if (reply.isError())
467 {
468- qWarning() << __PRETTY_FUNCTION__ << reply.error().message();
469+ qWarning() << reply.error().message();
470 return;
471 }
472
473
474=== modified file 'src/indicator/nmofono/vpn/vpn-manager.cpp'
475--- src/indicator/nmofono/vpn/vpn-manager.cpp 2016-02-23 09:05:16 +0000
476+++ src/indicator/nmofono/vpn/vpn-manager.cpp 2016-05-26 16:58:27 +0000
477@@ -122,7 +122,7 @@
478 QDBusPendingReply<QDBusObjectPath> reply = *call;
479 if (reply.isError())
480 {
481- qWarning() << __PRETTY_FUNCTION__ << reply.error().message();
482+ qWarning() << reply.error().message();
483 }
484 call->deleteLater();
485 }
486
487=== modified file 'src/indicator/nmofono/wifi/wifi-link-impl.cpp'
488--- src/indicator/nmofono/wifi/wifi-link-impl.cpp 2015-10-06 10:19:30 +0000
489+++ src/indicator/nmofono/wifi/wifi-link-impl.cpp 2016-05-26 16:58:27 +0000
490@@ -242,7 +242,7 @@
491 NM_DBUS_SERVICE, path.path(), m_dev->connection());
492 shap = make_shared<AccessPointImpl>(ap);
493 } catch(const exception &e) {
494- qWarning() << __PRETTY_FUNCTION__ << ": failed to create AccessPoint proxy for "<< path.path() << ": ";
495+ qWarning() << "Failed to create AccessPoint proxy for "<< path.path() << ": ";
496 qWarning() << "\t" << QString::fromStdString(e.what());
497 qWarning() << "\tIgnoring.";
498 return;
499@@ -261,7 +261,7 @@
500 /// @bug dbus-cpp internal logic exploded
501 // If this happens, indicator-network is in an unknown state with no clear way of
502 // recovering. The only reasonable way out is a graceful exit.
503- cerr << __PRETTY_FUNCTION__ << " Failed to run dbus service: " << e.what() << endl;
504+ cerr << " Failed to run dbus service: " << e.what() << endl;
505 }
506 }
507
508@@ -278,7 +278,7 @@
509 }
510 }
511 if (!shap) {
512- qWarning() << __PRETTY_FUNCTION__ << ": Tried to remove access point " << path.path() << " that has not been added.";
513+ qWarning() << "Tried to remove access point " << path.path() << " that has not been added.";
514 return;
515 }
516 m_rawAccessPoints = list;
517@@ -449,6 +449,8 @@
518 void
519 WifiLinkImpl::connect_to(AccessPoint::Ptr accessPoint)
520 {
521+ qDebug() << "Connecting to:" << accessPoint->ssid();
522+
523 try {
524 d->m_connecting = true;
525 QByteArray ssid = accessPoint->raw_ssid();
526@@ -479,11 +481,13 @@
527
528 QDBusObjectPath ac("/");
529 if (found) {
530+ qDebug() << "Connecting to known access point";
531 ac = d->m_nm->ActivateConnection(QDBusObjectPath(found->path()),
532 QDBusObjectPath(d->m_dev->path()),
533 accessPoint->object_path());
534 } else {
535 if (accessPoint->enterprise()) {
536+ qDebug() << "New connection to enterprise access point";
537 // activate system settings URI
538 QUrlQuery q;
539 q.addQueryItem("ssid", accessPoint->raw_ssid());
540@@ -496,6 +500,7 @@
541 }
542 });
543 } else {
544+ qDebug() << "New connection to regular access point";
545 QVariantDictMap conf;
546
547 /// @todo getting the ssid multiple times over dbus is stupid.
548@@ -519,7 +524,7 @@
549 // @bug default timeout expired: LP(#1361642)
550 // If this happens, indicator-network is in an unknown state with no clear way of
551 // recovering. The only reasonable way out is a graceful exit.
552- qWarning() << __PRETTY_FUNCTION__ << " Failed to activate connection: " << e.what();
553+ qWarning() << " Failed to activate connection: " << e.what();
554 }
555 }
556
557
558=== modified file 'src/indicator/nmofono/wwan/modem.cpp'
559--- src/indicator/nmofono/wwan/modem.cpp 2016-05-26 16:58:27 +0000
560+++ src/indicator/nmofono/wwan/modem.cpp 2016-05-26 16:58:27 +0000
561@@ -20,6 +20,7 @@
562 #include <nmofono/wwan/modem.h>
563
564 #include <ofono/dbus.h>
565+#include <QDebug>
566
567 #define slots
568 #include <qofono-qt5/qofonomodem.h>
569@@ -52,7 +53,7 @@
570 if (str == "roaming")
571 return Modem::ModemStatus::roaming;
572
573- qWarning() << __PRETTY_FUNCTION__ << ": Unknown status" << str;
574+ qWarning() << ": Unknown status" << str;
575 return Modem::ModemStatus::unknown;
576 }
577
578@@ -73,7 +74,7 @@
579 if (str == "lte")
580 return Modem::Bearer::lte;
581
582- qWarning() << __PRETTY_FUNCTION__ << ": Unknown techonology" << str;
583+ qWarning() << "Unknown technology" << str;
584 return Modem::Bearer::notAvailable;
585 }
586 }
587@@ -160,6 +161,8 @@
588
589 if (p.isReadyToUnlock() && m_shouldTriggerUnlock)
590 {
591+
592+ qDebug() << "SIM ready to unlock:" << p.simIdentifier();
593 m_shouldTriggerUnlock = false;
594 Q_EMIT p.readyToUnlock(p.name());
595 }
596@@ -760,6 +763,7 @@
597 void
598 Modem::notifyWhenReadyToUnlock()
599 {
600+ qDebug() << "Notify when ready to unlock" << simIdentifier();
601 d->m_shouldTriggerUnlock = true;
602 }
603
604
605=== modified file 'src/indicator/root-state.cpp'
606--- src/indicator/root-state.cpp 2015-08-14 16:11:08 +0000
607+++ src/indicator/root-state.cpp 2016-05-26 16:58:27 +0000
608@@ -288,7 +288,7 @@
609 try {
610 state["icon"] = createIcon(m_networkingIcons.first().toStdString());
611 } catch (exception &e) {
612- qWarning() << __PRETTY_FUNCTION__ << e.what();
613+ qWarning() << e.what();
614 }
615
616 for (const auto& icon: m_networkingIcons)
617
618=== modified file 'src/indicator/vpn-status-notifier.cpp'
619--- src/indicator/vpn-status-notifier.cpp 2015-12-17 10:41:14 +0000
620+++ src/indicator/vpn-status-notifier.cpp 2016-05-26 16:58:27 +0000
621@@ -64,7 +64,7 @@
622 QString id = activeVpnConnection->activeConnection().id();
623 QString message = REASON_MAP.value(reason, FAILED_MESSAGE).arg(id);
624
625- qDebug() << __PRETTY_FUNCTION__ << "VPN Connection Failed" << message;
626+ qDebug() << "VPN Connection Failed" << message;
627 m_notificationManager->notify(_("VPN Connection Failed"), message, "network-vpn", {}, {}, 5)->show();
628 }
629 }
630
631=== modified file 'src/menumodel-cpp/action-group-merger.cpp'
632--- src/menumodel-cpp/action-group-merger.cpp 2015-10-06 10:14:57 +0000
633+++ src/menumodel-cpp/action-group-merger.cpp 2016-05-26 16:58:27 +0000
634@@ -30,7 +30,7 @@
635 // then they will override each other in GActionGroup so let's catch that
636 // early on.
637 if (name_iter->second != action) {
638- qWarning() << __PRETTY_FUNCTION__ << ": Conflicting action names. \"" << action->name() << "\"";
639+ qWarning() << "Conflicting action names. \"" << action->name() << "\"";
640 /// @todo thow something.
641 return;
642 }
643@@ -73,7 +73,7 @@
644 auto iter = m_groups.find(group);
645 if (iter != m_groups.end()) {
646 /// @todo throw something.
647- std::cerr << __PRETTY_FUNCTION__ << ": Trying to add action group which was already added before." << std::endl;
648+ qWarning() << "Trying to add action group which was already added before.";
649 return;
650 }
651
652@@ -91,7 +91,7 @@
653 auto iter = m_groups.find(group);
654 if (iter == m_groups.end()) {
655 /// @todo throw something.
656- std::cerr << __PRETTY_FUNCTION__ << ": Trying to remove action group which was not added before." << std::endl;
657+ qWarning() << "Trying to remove action group which was not added before.";
658 return;
659 }
660 auto connections = m_groups[group];
661
662=== modified file 'src/menumodel-cpp/menu-item.cpp'
663--- src/menumodel-cpp/menu-item.cpp 2015-10-06 10:14:57 +0000
664+++ src/menumodel-cpp/menu-item.cpp 2016-05-26 16:58:27 +0000
665@@ -83,7 +83,7 @@
666 auto gicon = shared_ptr<GIcon>(g_icon_new_for_string(m_icon.toUtf8().constData(), &error), GObjectDeleter());
667 if (error)
668 {
669- qWarning() << __PRETTY_FUNCTION__ << error->message;
670+ qWarning() << error->message;
671 g_error_free(error);
672 return;
673 }
674
675=== modified file 'src/notify-cpp/notification.cpp'
676--- src/notify-cpp/notification.cpp 2015-12-11 14:58:11 +0000
677+++ src/notify-cpp/notification.cpp 2016-05-26 16:58:27 +0000
678@@ -95,12 +95,12 @@
679 {
680 if (d->m_id > 0 && d->m_open && d->m_expireTimeout <= 0)
681 {
682- qDebug() << __PRETTY_FUNCTION__ << "Closing notification:" << d->m_id;
683+ qDebug() << "Closing notification:" << d->m_id;
684 auto reply = d->m_notificationsInterface->CloseNotification(d->m_id);
685 reply.waitForFinished();
686 if (reply.isError())
687 {
688- qCritical() << __PRETTY_FUNCTION__ << reply.error().message();
689+ qCritical() << reply.error().message();
690 }
691 }
692 }
693@@ -221,7 +221,7 @@
694 reply.waitForFinished();
695 if (reply.isError())
696 {
697- qCritical() << __PRETTY_FUNCTION__ << reply.error().message();
698+ qCritical() << reply.error().message();
699 }
700 else
701 {
702@@ -241,7 +241,7 @@
703 reply.waitForFinished();
704 if (reply.isError())
705 {
706- qCritical() << __PRETTY_FUNCTION__ << reply.error().message();
707+ qCritical() << reply.error().message();
708 }
709 else
710 {
711
712=== modified file 'src/qpowerd/qpowerd.cpp'
713--- src/qpowerd/qpowerd.cpp 2015-07-28 08:26:51 +0000
714+++ src/qpowerd/qpowerd.cpp 2016-05-26 16:58:27 +0000
715@@ -68,7 +68,7 @@
716 reply.waitForFinished();
717 if (reply.isError())
718 {
719- qWarning() << __PRETTY_FUNCTION__ << reply.error().message();
720+ qWarning() << reply.error().message();
721 }
722 else
723 {
724
725=== modified file 'src/util/CMakeLists.txt'
726--- src/util/CMakeLists.txt 2016-02-15 09:31:38 +0000
727+++ src/util/CMakeLists.txt 2016-05-26 16:58:27 +0000
728@@ -2,6 +2,7 @@
729
730 set(UTIL_SOURCES
731 dbus-utils.cpp
732+ logging.cpp
733 unix-signal-handler.cpp
734 )
735
736
737=== added file 'src/util/logging.cpp'
738--- src/util/logging.cpp 1970-01-01 00:00:00 +0000
739+++ src/util/logging.cpp 2016-05-26 16:58:27 +0000
740@@ -0,0 +1,59 @@
741+/*
742+ * Copyright (C) 2016 Canonical, Ltd.
743+ *
744+ * This program is free software: you can redistribute it and/or modify it
745+ * under the terms of the GNU General Public License version 3, as published
746+ * by the Free Software Foundation.
747+ *
748+ * This program is distributed in the hope that it will be useful, but
749+ * WITHOUT ANY WARRANTY; without even the implied warranties of
750+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
751+ * PURPOSE. See the GNU General Public License for more details.
752+ *
753+ * You should have received a copy of the GNU General Public License along
754+ * with this program. If not, see <http://www.gnu.org/licenses/>.
755+ *
756+ * Author: Pete Woods <pete.woods@canonical.com>
757+ */
758+
759+#include <logging.h>
760+
761+namespace util
762+{
763+ void
764+ loggingFunction (QtMsgType type, const QMessageLogContext &context,
765+ const QString &msg)
766+ {
767+ QByteArray localMsg = msg.toLocal8Bit ();
768+ switch (type)
769+ {
770+ case QtMsgType::QtDebugMsg:
771+ fprintf (stderr, "Debug: %s (%s:%u, %s)\n",
772+ localMsg.constData (), context.file, context.line,
773+ context.function);
774+ break;
775+#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
776+ case QtMsgType::QtInfoMsg:
777+ fprintf (stderr, "Info: %s (%s:%u, %s)\n",
778+ localMsg.constData (), context.file, context.line,
779+ context.function);
780+ break;
781+#endif
782+ case QtMsgType::QtWarningMsg:
783+ fprintf (stderr, "Warning: %s (%s:%u, %s)\n",
784+ localMsg.constData (), context.file, context.line,
785+ context.function);
786+ break;
787+ case QtMsgType::QtCriticalMsg:
788+ fprintf (stderr, "Critical: %s (%s:%u, %s)\n",
789+ localMsg.constData (), context.file, context.line,
790+ context.function);
791+ break;
792+ case QtMsgType::QtFatalMsg:
793+ fprintf (stderr, "Fatal: %s (%s:%u, %s)\n",
794+ localMsg.constData (), context.file, context.line,
795+ context.function);
796+ abort ();
797+ }
798+ }
799+}
800
801=== added file 'src/util/logging.h'
802--- src/util/logging.h 1970-01-01 00:00:00 +0000
803+++ src/util/logging.h 2016-05-26 16:58:27 +0000
804@@ -0,0 +1,29 @@
805+/*
806+ * Copyright (C) 2016 Canonical, Ltd.
807+ *
808+ * This program is free software: you can redistribute it and/or modify it
809+ * under the terms of the GNU General Public License version 3, as published
810+ * by the Free Software Foundation.
811+ *
812+ * This program is distributed in the hope that it will be useful, but
813+ * WITHOUT ANY WARRANTY; without even the implied warranties of
814+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
815+ * PURPOSE. See the GNU General Public License for more details.
816+ *
817+ * You should have received a copy of the GNU General Public License along
818+ * with this program. If not, see <http://www.gnu.org/licenses/>.
819+ *
820+ * Author: Pete Woods <pete.woods@canonical.com>
821+ */
822+
823+#pragma once
824+
825+#include <QMessageLogContext>
826+#include <QString>
827+
828+namespace util
829+{
830+ void
831+ loggingFunction (QtMsgType type, const QMessageLogContext &context,
832+ const QString &msg);
833+}
834
835=== modified file 'tests/unit/secret-agent/secret-agent-main.cpp'
836--- tests/unit/secret-agent/secret-agent-main.cpp 2016-02-15 09:31:38 +0000
837+++ tests/unit/secret-agent/secret-agent-main.cpp 2016-05-26 16:58:27 +0000
838@@ -32,6 +32,34 @@
839
840 using namespace std;
841
842+class DummyCredentialStore : public agent::CredentialStore
843+{
844+public:
845+ DummyCredentialStore() {
846+ }
847+
848+ ~DummyCredentialStore() {
849+ }
850+
851+ void
852+ save (const QString&, const QString&, const QString&, const QString&,
853+ const QString&)
854+ {
855+ }
856+
857+ QMap<QString, QString>
858+ get (const QString&, const QString&)
859+ {
860+ return QMap<QString, QString> ();
861+ }
862+
863+ void
864+ clear (const QString&)
865+ {
866+ }
867+
868+};
869+
870 int main(int argc, char *argv[]) {
871 QCoreApplication application(argc, argv);
872 DBusTypes::registerMetaTypes();
873@@ -49,7 +77,7 @@
874
875 auto secretAgent = make_unique<agent::SecretAgent>(
876 make_shared<notify::NotificationManager>(GETTEXT_PACKAGE),
877- make_shared<agent::KeyringCredentialStore>(),
878+ make_shared<DummyCredentialStore>(),
879 QDBusConnection::systemBus(), QDBusConnection::sessionBus());
880
881 if (argc == 2 && QString("--print-address") == argv[1]) {
882
883=== modified file 'tests/unit/secret-agent/test-secret-agent.cpp'
884--- tests/unit/secret-agent/test-secret-agent.cpp 2016-02-15 09:31:38 +0000
885+++ tests/unit/secret-agent/test-secret-agent.cpp 2016-05-26 16:58:27 +0000
886@@ -261,9 +261,9 @@
887 reply.waitForFinished();
888
889 ASSERT_TRUE(reply.isError());
890- EXPECT_EQ(QDBusError::InternalError, reply.error().type());
891- EXPECT_EQ("No password found for this connection.",
892- reply.error().message());
893+ EXPECT_EQ("org.freedesktop.NetworkManager.SecretAgent.NoSecrets", reply.error().name().toStdString());
894+ EXPECT_EQ("No secrets found for this connection.",
895+ reply.error().message().toStdString());
896 }
897
898 /* Tests that if we request secrets and then cancel the request
899
900=== modified file 'tests/utils/CMakeLists.txt'
901--- tests/utils/CMakeLists.txt 2014-08-05 21:16:22 +0000
902+++ tests/utils/CMakeLists.txt 2016-05-26 16:58:27 +0000
903@@ -8,7 +8,8 @@
904 action-utils.cpp
905 )
906
907-qt5_use_modules(
908+target_link_libraries(
909 test-utils
910- Core
911+ Qt5::Core
912+ util
913 )
914
915=== modified file 'tests/utils/main.cpp'
916--- tests/utils/main.cpp 2016-03-04 11:11:56 +0000
917+++ tests/utils/main.cpp 2016-05-26 16:58:27 +0000
918@@ -25,6 +25,8 @@
919
920 #include <libqtdbusmock/DBusMock.h>
921
922+#include <util/logging.h>
923+
924 using namespace QtDBusMock;
925
926 class Runner: public QObject
927@@ -39,6 +41,8 @@
928
929 int main(int argc, char **argv)
930 {
931+ qInstallMessageHandler(util::loggingFunction);
932+
933 qputenv("LANG", "C.UTF-8");
934 unsetenv("LC_ALL");
935 unsetenv("GDM_LANG");

Subscribers

People subscribed via source and target branches