Commit 32d9089d authored by akalin@chromium.org's avatar akalin@chromium.org

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
parent 50db9b0e
......@@ -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
......@@ -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 "
......
......@@ -29,7 +29,7 @@ int PushNotificationsSendUpdateTask::ProcessStart() {
scoped_ptr<buzz::XmlElement> stanza(
MakeUpdateMessage(notification_,
GetClient()->jid().BareJid()));
VLOG(1) << "Sending notification " << notification_.ToString()
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);
......
......@@ -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,13 +56,13 @@ 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: "
DVLOG(1) << "Push notifications: Subscription response: "
<< XmlElementToString(*stanza);
// We've receieved a response to our subscription request.
if (stanza->HasAttr(buzz::QN_TYPE) &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment