diff options
author | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-13 22:05:58 +0000 |
---|---|---|
committer | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-13 22:05:58 +0000 |
commit | 32d9089d37a635069373f07f9ee7c1dae449c1ce (patch) | |
tree | 88a16c096053e965090dedfa10b901a81dbbf39c /jingle | |
parent | 50db9b0e3d90d4bb5cb59b03072d1370f8daeb87 (diff) | |
download | chromium_src-32d9089d37a635069373f07f9ee7c1dae449c1ce.zip chromium_src-32d9089d37a635069373f07f9ee7c1dae449c1ce.tar.gz chromium_src-32d9089d37a635069373f07f9ee7c1dae449c1ce.tar.bz2 |
Clean up logging for push_notifications_*.cc
Make Notification::ToString() base64 the data member (since it can hold
binary data).
Convert VLOGs to DVLOGs for push_notifications_*.cc.
BUG=141692
Review URL: https://chromiumcodereview.appspot.com/10828264
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151367 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'jingle')
4 files changed, 22 insertions, 10 deletions
diff --git a/jingle/notifier/listener/notification_defines.cc b/jingle/notifier/listener/notification_defines.cc index 2f65775..f496df1 100644 --- a/jingle/notifier/listener/notification_defines.cc +++ b/jingle/notifier/listener/notification_defines.cc @@ -6,6 +6,11 @@ #include <cstddef> +#include "base/json/json_writer.h" +#include "base/logging.h" +#include "base/string_util.h" +#include "base/values.h" + namespace notifier { Subscription::Subscription() {} @@ -60,7 +65,14 @@ bool Notification::Equals(const Notification& other) const { } std::string Notification::ToString() const { - return "{ channel: \"" + channel + "\", data: \"" + data + "\" }"; + // Put into a DictionaryValue and convert to a string; this gives a + // nice hex-encoding of |data|, which may be a binary string. + DictionaryValue dict; + dict.SetString("channel", channel); + dict.SetString("data", data); + std::string str; + base::JSONWriter::Write(&dict, &str); + return str; } } // namespace notifier diff --git a/jingle/notifier/listener/push_notifications_listen_task.cc b/jingle/notifier/listener/push_notifications_listen_task.cc index 3a665ee..ad1da9f 100644 --- a/jingle/notifier/listener/push_notifications_listen_task.cc +++ b/jingle/notifier/listener/push_notifications_listen_task.cc @@ -38,7 +38,7 @@ int PushNotificationsListenTask::ProcessResponse() { return STATE_BLOCKED; } - VLOG(1) << "Received stanza " << XmlElementToString(*stanza); + DVLOG(1) << "Received stanza " << XmlElementToString(*stanza); // The push notifications service does not need us to acknowledge receipt of // the notification to the buzz server. @@ -72,7 +72,7 @@ int PushNotificationsListenTask::ProcessResponse() { LOG(WARNING) << "No data element found in push element " << XmlElementToString(*push_element); } - VLOG(1) << "Received notification " << notification.ToString(); + DVLOG(1) << "Received notification " << notification.ToString(); delegate_->OnNotificationReceived(notification); } else { LOG(WARNING) << "No push element found in stanza " diff --git a/jingle/notifier/listener/push_notifications_send_update_task.cc b/jingle/notifier/listener/push_notifications_send_update_task.cc index d669a37..50ec15e 100644 --- a/jingle/notifier/listener/push_notifications_send_update_task.cc +++ b/jingle/notifier/listener/push_notifications_send_update_task.cc @@ -29,8 +29,8 @@ int PushNotificationsSendUpdateTask::ProcessStart() { scoped_ptr<buzz::XmlElement> stanza( MakeUpdateMessage(notification_, GetClient()->jid().BareJid())); - VLOG(1) << "Sending notification " << notification_.ToString() - << " as stanza " << XmlElementToString(*stanza); + DVLOG(1) << "Sending notification " << notification_.ToString() + << " as stanza " << XmlElementToString(*stanza); if (SendStanza(stanza.get()) != buzz::XMPP_RETURN_OK) { LOG(WARNING) << "Could not send stanza " << XmlElementToString(*stanza); } diff --git a/jingle/notifier/listener/push_notifications_subscribe_task.cc b/jingle/notifier/listener/push_notifications_subscribe_task.cc index 40f0338..33f9949 100644 --- a/jingle/notifier/listener/push_notifications_subscribe_task.cc +++ b/jingle/notifier/listener/push_notifications_subscribe_task.cc @@ -39,12 +39,12 @@ bool PushNotificationsSubscribeTask::HandleStanza( } int PushNotificationsSubscribeTask::ProcessStart() { - VLOG(1) << "Push notifications: Subscription task started."; + DVLOG(1) << "Push notifications: Subscription task started."; scoped_ptr<buzz::XmlElement> iq_stanza( MakeSubscriptionMessage(subscriptions_, GetClient()->jid(), task_id())); std::string stanza_str = XmlElementToString(*iq_stanza.get()); - VLOG(1) << "Push notifications: Subscription stanza: " + DVLOG(1) << "Push notifications: Subscription stanza: " << XmlElementToString(*iq_stanza.get()); if (SendStanza(iq_stanza.get()) != buzz::XMPP_RETURN_OK) { @@ -56,14 +56,14 @@ int PushNotificationsSubscribeTask::ProcessStart() { } int PushNotificationsSubscribeTask::ProcessResponse() { - VLOG(1) << "Push notifications: Subscription response received."; + DVLOG(1) << "Push notifications: Subscription response received."; const buzz::XmlElement* stanza = NextStanza(); if (stanza == NULL) { return STATE_BLOCKED; } std::string stanza_str = XmlElementToString(*stanza); - VLOG(1) << "Push notifications: Subscription response: " - << XmlElementToString(*stanza); + DVLOG(1) << "Push notifications: Subscription response: " + << XmlElementToString(*stanza); // We've receieved a response to our subscription request. if (stanza->HasAttr(buzz::QN_TYPE) && stanza->Attr(buzz::QN_TYPE) == buzz::STR_RESULT) { |