express-bunyan-logger
Advanced tools
Comparing version 0.1.4 to 0.2.0
15
index.js
@@ -18,2 +18,3 @@ var bunyan = require('bunyan'), | ||
parseUA = true, | ||
excludes, | ||
levelFn = defaultLevelFn; | ||
@@ -38,2 +39,7 @@ | ||
if (opts.excludes) { | ||
excludes = opts.excludes; | ||
delete opts.excludes; | ||
} | ||
return function (err, req, res, next) { | ||
@@ -43,3 +49,3 @@ var startTime = Date.now(); | ||
function logging(incoming) { | ||
if(!incoming) { | ||
if (!incoming) { | ||
res.removeListener('finish', logging); | ||
@@ -98,2 +104,9 @@ res.removeListener('close', logging); | ||
err && (meta.err = err); | ||
if (excludes) { | ||
excludes.forEach(function(ex) { | ||
delete meta[ex]; | ||
}); | ||
} | ||
logFn.call(logger, meta, format(meta)); | ||
@@ -100,0 +113,0 @@ } |
{ | ||
"name": "express-bunyan-logger", | ||
"version": "0.1.4", | ||
"version": "0.2.0", | ||
"description": "a bunyan logger middleware for express", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -62,2 +62,6 @@ # Express-bunyan-logger | ||
### options.excludes | ||
Array of string, Those fields will be excluded from meta object which passed to bunyan | ||
### options.immediate | ||
@@ -64,0 +68,0 @@ |
@@ -73,5 +73,32 @@ var express = require('express'); | ||
it.only('test errorLogger', function(done) { | ||
it('test excludes', function(done) { | ||
var app = express(); | ||
var output = st(); | ||
app.use(bunyanLogger({ | ||
stream: output, | ||
excludes: ['req', 'res', 'nont'] | ||
})); | ||
app.get('/', function(req, res) { | ||
res.send('GET /'); | ||
}); | ||
request(app) | ||
.get('/') | ||
.expect('GET /', function(err, res) { | ||
var json = JSON.parse(output.content.toString()); | ||
assert.equal(json.name, 'express'); | ||
assert.equal(json.url, '/'); | ||
assert.equal(json['status-code'], 200); | ||
assert(!json.res); | ||
assert(!json.req); | ||
done(); | ||
}); | ||
}); | ||
it('test errorLogger', function(done) { | ||
var app = express(); | ||
var output = st(); | ||
app.use(app.router); | ||
@@ -78,0 +105,0 @@ app.use(bunyanLogger.errorLogger({ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13280
269
75