Use Date.toISOString for logging
This commit is contained in:
parent
3b9b5e26f4
commit
88ce0cee99
@ -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");
|
||||
},
|
||||
};
|
||||
|
@ -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) {
|
||||
|
@ -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");
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user