Merge pull request #5180 from mattbailey/production-json-logging

use JSON logging and ISO8601 timestamp for production logs
This commit is contained in:
Barış Soner Uşaklı
2016-11-03 18:19:55 +02:00
committed by GitHub

6
app.js
View File

@@ -38,9 +38,11 @@ winston.add(winston.transports.Console, {
colorize: true,
timestamp: function () {
var date = new Date();
return date.getDate() + '/' + (date.getMonth() + 1) + ' ' + date.toTimeString().substr(0,5) + ' [' + global.process.pid + ']';
return (global.env === 'production') ? date.toJSON() : date.getDate() + '/' + (date.getMonth() + 1) + ' ' + date.toTimeString().substr(0,5) + ' [' + global.process.pid + ']';
},
level: nconf.get('log-level') || (global.env === 'production' ? 'info' : 'verbose')
level: nconf.get('log-level') || (global.env === 'production' ? 'info' : 'verbose'),
json: (global.env === 'production'),
stringify: (global.env === 'production')
});