Merge pull request #2787 from thelounge/xpaw/utc-log

Use Date.toISOString for logging
This commit is contained in:
Pavel Djundik 2018-09-24 15:24:33 +03:00 committed by GitHub
commit d7a37cfdc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 13 deletions

View File

@ -2,10 +2,11 @@
const colors = require("chalk");
const read = require("read");
const moment = require("moment");
function timestamp() {
return colors.dim(module.exports.getHumanDate());
const datetime = (new Date()).toISOString().split(".")[0].replace("T", " ");
return colors.dim(datetime);
}
module.exports = {
@ -31,8 +32,4 @@ module.exports = {
options.prompt = [timestamp(), colors.cyan("[PROMPT]"), options.text].join(" ");
read(options, callback);
},
getHumanDate(ts) {
return moment(ts).format("YYYY-MM-DD HH:mm:ss");
},
};

View File

@ -40,7 +40,7 @@ class TextFileMessageStorage {
return;
}
let line = `[${log.getHumanDate(msg.time)}] `;
let line = `[${msg.time.toISOString()}] `;
// message types from src/models/msg.js
switch (msg.type) {

View File

@ -2,9 +2,7 @@
const expect = require("chai").expect;
const os = require("os");
const moment = require("moment");
const Helper = require("../../src/helper");
const log = require("../../src/log");
describe("Helper", function() {
describe("#expandHome", function() {
@ -54,8 +52,4 @@ describe("Helper", function() {
expect(version).to.match(/v[0-9]+\.[0-9]+\.[0-9]+/);
});
});
describe("#getHumanDate()", function() {
expect(log.getHumanDate(moment(1455090480000).utc())).to.equal("2016-02-10 07:48:00");
});
});