From df237fa16a184ce40c55b8a6e9e92511f79fcda1 Mon Sep 17 00:00:00 2001 From: vegawong Date: Sun, 9 Sep 2018 14:32:20 +0800 Subject: [PATCH] fix: support localTimeZone for logger `pretty-timestamped` format (#984) * feat: support localTimeZone for logger `pretty-timestamped` format * feat: use `date-fns` to format log time --- src/lib/logger.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/logger.js b/src/lib/logger.js index ac7748f1f..dc280f453 100644 --- a/src/lib/logger.js +++ b/src/lib/logger.js @@ -6,6 +6,7 @@ const chalk = require('chalk'); const Utils = require('./utils'); const pkgJSON = require('../../package.json'); const _ = require('lodash'); +const {format} = require('date-fns'); /** * Match the level based on buyan severity scale @@ -101,7 +102,7 @@ function setup(logs) { } else if (target.format === 'pretty-timestamped') { // making fake stream for pretty pritting stream.write = (obj) => { - destination.write(`${obj.time.toISOString()}${print(obj.level, obj.msg, obj, destinationIsTTY)}\n`); + destination.write(`[${format(obj.time, 'YYYY-MM-DD HH:mm:ss')}] ${print(obj.level, obj.msg, obj, destinationIsTTY)}\n`); }; } else { stream.write = (obj) => {