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");
}
else {
var now = new Date()
this.write(now.getFullYear() + "-" + (now.getMonth() < 9 ? '0' : '') +
(now.getMonth() + 1) + "-" +
(now.getDate() < 10 ? '0' : '') + (now.getDate()) + " " +
(now.getHours() < 10 ? '0' : '') + now.getHours() + ":" +
(now.getMinutes() < 10 ? '0' : '') + now.getMinutes() + ":" +
(now.getSeconds() < 10 ? '0' : '') + now.getSeconds() + " " +
msg + "\n");
function pad(n, len) {
let s = "0000" + n;
return s.slice(-len);
}
let now = new Date();
let year = pad(now.getFullYear(), 4);
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");
}
},