express-bunyan-logger
Advanced tools
Comparing version 0.2.1 to 0.2.2
25
index.js
@@ -106,9 +106,23 @@ var bunyan = require('bunyan'), | ||
var json = meta; | ||
if (excludes) { | ||
excludes.forEach(function(ex) { | ||
delete meta[ex]; | ||
}); | ||
json = null; | ||
if (!~excludes.indexOf('*')) { | ||
json = {}; | ||
var exs = {}; | ||
excludes.forEach(function(ex) { | ||
exs[ex] = true; | ||
}); | ||
for (var p in meta) | ||
if (!exs[p]) | ||
json[p] = meta[p]; | ||
} | ||
} | ||
logFn.call(logger, meta, format(meta)); | ||
if (!json) { | ||
logFn.call(logger, format(meta)); | ||
} else { | ||
logFn.call(logger, json, format(meta)); | ||
} | ||
} | ||
@@ -120,2 +134,3 @@ | ||
} | ||
res.on('finish', logging); | ||
@@ -122,0 +137,0 @@ res.on('close', logging); |
{ | ||
"name": "express-bunyan-logger", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "a bunyan logger middleware for express", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -99,2 +99,29 @@ var express = require('express'); | ||
it('test excludes all', function(done) { | ||
var app = express(); | ||
var output = st(); | ||
app.use(bunyanLogger({ | ||
stream: output, | ||
excludes: ['req', '*'] | ||
})); | ||
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'); | ||
console.log(json); | ||
assert(!json.url); | ||
assert(!json['status-code']); | ||
assert(!json.res); | ||
assert(!json.req); | ||
done(); | ||
}); | ||
}); | ||
it('test errorLogger', function(done) { | ||
@@ -101,0 +128,0 @@ var app = express(); |
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
14405
12
308