diff --git a/lib/cli.js b/lib/cli.js index b99267753..60a55377b 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -91,6 +91,8 @@ function afterConfigLoad() { if (!config.user_agent) config.user_agent = 'Sinopia/'+pkg.version; if (!config.self_path) config.self_path = config_path; + logger.setup(config.logs) + var hostport = get_hostport(); server(config).listen(hostport[1], hostport[0]); logger.logger.warn({addr: 'http://'+hostport[0]+':'+hostport[1]+'/'}, 'Server is listening on @{addr}'); diff --git a/lib/config_def.yaml b/lib/config_def.yaml index 96f47194a..4ed594a5c 100644 --- a/lib/config_def.yaml +++ b/lib/config_def.yaml @@ -51,6 +51,6 @@ packages: # # parameters for stdout and stderr: format: json | pretty # {type: 'stdout', format: 'pretty', level: 'debug'}, -log: +logs: - {type: stdout, format: pretty, level: http} #- {type: file, path: sinopia.log, level: info} diff --git a/lib/logger.js b/lib/logger.js index b12ae4d04..6bb5b2a9e 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -38,7 +38,6 @@ module.exports.setup = function(logs) { } } else { stream.write = function(obj) { - obj = log_filter(obj); dest.write(JSON.stringify(obj, Logger.safeCycles()) + "\n"); } } @@ -48,7 +47,6 @@ module.exports.setup = function(logs) { Logger.emit('error', err); }); stream.write = function(obj) { - obj = log_filter(obj); dest.write(JSON.stringify(obj, Logger.safeCycles()) + "\n"); } } else { diff --git a/lib/middleware.js b/lib/middleware.js index b296845f0..1fde5e16a 100644 --- a/lib/middleware.js +++ b/lib/middleware.js @@ -89,7 +89,11 @@ function md5sum(data) { module.exports.log_and_etagify = function(req, res, next) { // logger req.log = Logger.logger.child({sub: 'in'}); - req.log.info({req: req, ip: req.ip}, '@{ip} requested \'@{req.method} @{req.url}\''); + + var _auth = req.headers.authorization + if (_auth) req.headers.authorization = '' + req.log.info({req: req, ip: req.ip}, '@{ip} requested \'@{req.method} @{req.url}\'') + if (_auth) req.headers.authorization = _auth var bytesin = 0; req.on('data', function(chunk){ bytesin += chunk.length });