summaryrefslogtreecommitdiffstats
path: root/remoting/webapp/remoting.js
diff options
context:
space:
mode:
authorjamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-06 20:45:42 +0000
committerjamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-06 20:45:42 +0000
commit4ce1cf88fd9677e6c89ec1e40534148827b148cb (patch)
tree677c6f0e6f4872208292959626121ce69487e139 /remoting/webapp/remoting.js
parentfd172369307dcdadc3771053c38b1aa387fce495 (diff)
downloadchromium_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/remoting.js')
-rw-r--r--remoting/webapp/remoting.js24
1 files changed, 24 insertions, 0 deletions
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 + ']';
+};