Bug 708498 - Log milliseconds in TPS, code tidy; r=rnewman

This commit is contained in:
Gregory Szorc 2011-12-09 11:11:04 -08:00
Родитель 76ea15827b
Коммит 4f1fb5af10
1 изменённых файлов: 17 добавлений и 8 удалений

Просмотреть файл

@ -128,14 +128,23 @@ var Logger =
this.write(msg + "\n"); this.write(msg + "\n");
} }
else { else {
var now = new Date() function pad(n, len) {
this.write(now.getFullYear() + "-" + (now.getMonth() < 9 ? '0' : '') + let s = "0000" + n;
(now.getMonth() + 1) + "-" + return s.slice(-len);
(now.getDate() < 10 ? '0' : '') + (now.getDate()) + " " + }
(now.getHours() < 10 ? '0' : '') + now.getHours() + ":" +
(now.getMinutes() < 10 ? '0' : '') + now.getMinutes() + ":" + let now = new Date();
(now.getSeconds() < 10 ? '0' : '') + now.getSeconds() + " " + let year = pad(now.getFullYear(), 4);
msg + "\n"); let month = pad(now.getMonth() + 1, 2);
let day = pad(now.getDate(), 2);
let hour = pad(now.getHours(), 2);
let minutes = pad(now.getMinutes(), 2);
let seconds = pad(now.getSeconds(), 2);
let ms = pad(now.getMilliseconds(), 3);
this.write(year + "-" + month + "-" + day + " " +
hour + ":" + minutes + ":" + seconds + "." + ms + " " +
msg + "\n");
} }
}, },