diff options
author | jamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-06 20:45:42 +0000 |
---|---|---|
committer | jamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-06 20:45:42 +0000 |
commit | 4ce1cf88fd9677e6c89ec1e40534148827b148cb (patch) | |
tree | 677c6f0e6f4872208292959626121ce69487e139 /remoting/webapp | |
parent | fd172369307dcdadc3771053c38b1aa387fce495 (diff) | |
download | chromium_src-4ce1cf88fd9677e6c89ec1e40534148827b148cb.zip chromium_src-4ce1cf88fd9677e6c89ec1e40534148827b148cb.tar.gz chromium_src-4ce1cf88fd9677e6c89ec1e40534148827b148cb.tar.bz2 |
Added timestamp logging to iq stanzas.
BUG=None
TEST=Manual
Review URL: https://chromiumcodereview.appspot.com/10542030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140831 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/webapp')
-rw-r--r-- | remoting/webapp/client_screen.js | 2 | ||||
-rw-r--r-- | remoting/webapp/client_session.js | 5 | ||||
-rw-r--r-- | remoting/webapp/remoting.js | 24 |
3 files changed, 28 insertions, 3 deletions
diff --git a/remoting/webapp/client_screen.js b/remoting/webapp/client_screen.js index baa7e56..f57c937 100644 --- a/remoting/webapp/client_screen.js +++ b/remoting/webapp/client_screen.js @@ -382,7 +382,7 @@ function setConnectionInterruptedButtonsText_() { */ function parseServerResponse_(xhr) { remoting.supportHostsXhr_ = null; - console.log('parseServerResponse: xhr = ' + xhr); + console.log('parseServerResponse: xhr =', xhr); if (xhr.status == 200) { var host = /** @type {{data: {jabberId: string, publicKey: string}}} */ jsonParseSafe(xhr.responseText); diff --git a/remoting/webapp/client_session.js b/remoting/webapp/client_session.js index dc2cbf0..98a5652 100644 --- a/remoting/webapp/client_session.js +++ b/remoting/webapp/client_session.js @@ -426,7 +426,7 @@ remoting.ClientSession.prototype.hasReceivedFrame = function() { * @return {void} Nothing. */ remoting.ClientSession.prototype.sendIq_ = function(msg) { - console.log(remoting.formatIq.prettifySendIq(msg)); + console.log(remoting.timestamp(), remoting.formatIq.prettifySendIq(msg)); // Extract the session id, so we can close the session later. var parser = new DOMParser(); var iqNode = parser.parseFromString(msg, 'text/xml').firstChild; @@ -465,7 +465,8 @@ remoting.ClientSession.prototype.connectPluginToWcs_ = var forwardIq = plugin.onIncomingIq.bind(plugin); /** @param {string} stanza The IQ stanza received. */ var onIncomingIq = function(stanza) { - console.log(remoting.formatIq.prettifyReceiveIq(stanza)); + console.log(remoting.timestamp(), + remoting.formatIq.prettifyReceiveIq(stanza)); forwardIq(stanza); } remoting.wcs.setOnIq(onIncomingIq); diff --git a/remoting/webapp/remoting.js b/remoting/webapp/remoting.js index 21649fb..188deb6 100644 --- a/remoting/webapp/remoting.js +++ b/remoting/webapp/remoting.js @@ -296,3 +296,27 @@ function jsonParseSafe(jsonString) { return undefined; } } + +/** + * Return the current time as a formatted string suitable for logging. + * + * @return {string} The current time, formatted as [mmdd/hhmmss.xyz] +*/ +remoting.timestamp = function() { + /** + * @param {number} num A number. + * @return {string} The number, formatted as a string of the specified length. + */ + var pad = function(num, len) { + var result = num.toString(); + if (result.length < len) { + result = new Array(len - result.length + 1).join('0') + result; + } + return result; + }; + var now = new Date(); + var timestamp = pad(now.getMonth() + 1, 2) + pad(now.getDate(), 2) + '/' + + pad(now.getHours(), 2) + pad(now.getMinutes(), 2) + + pad(now.getSeconds(), 2) + '.' + pad(now.getMilliseconds(), 3); + return '[' + timestamp + ']'; +}; |