0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-02-17 23:45:29 -05:00

Implement timestamped pretty logging to stdout or stderr

https://github.com/verdaccio/verdaccio/pull/68
This commit is contained in:
Jannis Achstetter 2016-10-06 09:35:10 +02:00 committed by trent.earl
parent 9f9c0fae71
commit 3d9af3152e
2 changed files with 6 additions and 1 deletions

View file

@ -109,7 +109,7 @@ packages:
# parameters for file: name is filename
# {type: 'file', path: 'verdaccio.log', level: 'debug'},
#
# parameters for stdout and stderr: format: json | pretty
# parameters for stdout and stderr: format: json | pretty | pretty-timestamped
# {type: 'stdout', format: 'pretty', level: 'debug'},
logs:
- {type: stdout, format: pretty, level: http}

View file

@ -32,6 +32,11 @@ module.exports.setup = function(logs) {
stream.write = function(obj) {
dest.write(print(obj.level, obj.msg, obj, dest.isTTY) + '\n')
}
} else if (target.format === 'pretty-timestamped') {
// making fake stream for prettypritting
stream.write = function(obj) {
dest.write(obj.time.toISOString() + print(obj.level, obj.msg, obj, dest.isTTY) + '\n')
}
} else {
stream.write = function(obj) {
dest.write(JSON.stringify(obj, Logger.safeCycles()) + '\n')