clean up the log output a bit
This commit is contained in:
parent
ffb5e8c6c8
commit
5eb9bedb1b
13
src/cli/log.js
Normal file
13
src/cli/log.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
let _ = require('lodash');
|
||||
let ansicolors = require('ansicolors');
|
||||
|
||||
let log = _.restParam(function (color, label, rest1) {
|
||||
console.log.apply(console, [color(` ${_.trim(label)} `)].concat(rest1));
|
||||
});
|
||||
|
||||
let color = require('./color');
|
||||
exports.green = _.partial(log, color.green);
|
||||
exports.red = _.partial(log, color.red);
|
||||
exports.yellow = _.partial(log, color.yellow);
|
|
@ -28,14 +28,14 @@ let color = _.memoize(function (name) {
|
|||
});
|
||||
|
||||
let type = _.memoize(function (t) {
|
||||
return _.chain(t).padLeft(6).trunc(6).thru(color(t)).value();
|
||||
return _.chain(t).pad(6).trunc(6).thru(color(t)).value();
|
||||
});
|
||||
|
||||
let workerType = process.env.kbnWorkerType ? `${type(process.env.kbnWorkerType)}: ` : '';
|
||||
let workerType = process.env.kbnWorkerType ? `${type(process.env.kbnWorkerType)} ` : '';
|
||||
|
||||
module.exports = class KbnLoggerJsonFormat extends LogFormat {
|
||||
format(data) {
|
||||
let time = color('time')(moment(data.timestamp).format());
|
||||
let time = color('time')(moment(data.timestamp).format('LTS'));
|
||||
let msg = data.error ? color('error')(data.error.stack) : color('message')(data.message);
|
||||
|
||||
let tags = _(data.tags)
|
||||
|
@ -46,6 +46,6 @@ module.exports = class KbnLoggerJsonFormat extends LogFormat {
|
|||
return s + `[${ color(t)(t) }]`;
|
||||
}, '');
|
||||
|
||||
return `${workerType}${type(data.type)}: [${time}] ${tags} ${msg}`;
|
||||
return `${workerType}${type(data.type)} [${time}] ${tags} ${msg}`;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@ module.exports = function (kbnServer, server, config) {
|
|||
}
|
||||
|
||||
server.log('warning', {
|
||||
tmpl: 'Plugin dir <%= dir %> does not exist',
|
||||
tmpl: '<%= err.code %>: Unable to scan non-existent directory for plugins "<%= dir %>"',
|
||||
err: err,
|
||||
dir: dir
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue