Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-bunyan-logger

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-bunyan-logger - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

2

index.js

@@ -106,3 +106,3 @@ var bunyan = require('bunyan'),

next();
next(err);
};

@@ -109,0 +109,0 @@ };

{
"name": "express-bunyan-logger",
"version": "0.1.3",
"description": "a bunyan logger middleware for express",
"main": "index.js",
"scripts": {
"test": "make test"
},
"repository": {
"type": "git",
"url": "https://github.com/villadora/express-bunyan-logger.git"
},
"keywords": [
"express",
"logger",
"bunyan"
],
"dependencies": {
"bunyan": "~0.23.0",
"useragent": "~2.0.8"
},
"devDependencies": {
"express": "3.x",
"supertest": "*",
"grunt": "~0.4.1",
"jshint": "~2.1.9",
"mocha": "~1.12.0",
"grunt-contrib-jshint": "~0.3.0",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-watch": "~0.3.0"
},
"readmeFilename": "README.md",
"author": {
"name": "wei.gao",
"email": "jky239@gmail.com"
},
"contributors": [
"Ognian Tschakalov <ognian.tschakalov@ogi-it.com>",
"Simon Wade <simon.wade@gmail.com>",
"Wei Gao <jky239@gmail.com>"
],
"license": "BSD"
"name": "express-bunyan-logger",
"version": "0.1.4",
"description": "a bunyan logger middleware for express",
"main": "index.js",
"scripts": {
"test": "make test"
},
"repository": {
"type": "git",
"url": "https://github.com/villadora/express-bunyan-logger.git"
},
"keywords": [
"express",
"logger",
"bunyan"
],
"dependencies": {
"bunyan": "~0.23.0",
"useragent": "~2.0.8"
},
"devDependencies": {
"express": "3.x",
"grunt": "~0.4.1",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-jshint": "~0.3.0",
"grunt-contrib-watch": "~0.3.0",
"jshint": "~2.1.9",
"mocha": "~1.12.0",
"supertest": "*",
"through2": "^0.5.1"
},
"readmeFilename": "README.md",
"author": {
"name": "wei.gao",
"email": "jky239@gmail.com"
},
"contributors": [
"Ognian Tschakalov <ognian.tschakalov@ogi-it.com>",
"Simon Wade <simon.wade@gmail.com>",
"Wei Gao <jky239@gmail.com>"
],
"license": "BSD"
}

@@ -1,53 +0,124 @@

var express = require('express'),
request = require('supertest'),
bunyanLogger = require('../');
var express = require('express');
var assert = require('assert');
var request = require('supertest');
var through = require('through2');
var bunyanLogger = require('../');
require('buffer');
function st(end) {
return through(function (chunk, enc, next) {
if(this.content)
this.content = Buffer.concat([content, chunk]);
else
this.content = chunk;
next();
}, end);
}
describe('bunyan-logger', function() {
it('test logger', function(done) {
var app = express();
app.use(bunyanLogger({}));
app.get('/', function(req, res) {
res.send('GET /');
});
it('test logger', function(done) {
var app = express();
var output = st();
request(app)
.get('/')
.expect('GET /', function(err, res) {
if(err)
done(err);
else
done();
});
app.use(bunyanLogger({
stream: output
}));
app.get('/', function(req, res) {
res.send('GET /');
});
it('test 404 statusCode', function(done) {
var app = express();
app.use(bunyanLogger());
request(app)
.get('/missing')
.end(function(err, res) {
done();
});
request(app)
.get('/')
.expect('GET /', function(err, res) {
if(err)
done(err);
else {
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 && json.req);
done();
}
});
});
it('test 404 statusCode', function(done) {
var app = express();
var output = st();
app.use(bunyanLogger({
stream: output
}));
request(app)
.get('/missing')
.end(function(err, res) {
var json = JSON.parse(output.content.toString());
assert.equal(json.name, 'express');
assert.equal(json.url, '/missing');
assert.equal(json['status-code'], 404);
assert(json.res && json.req);
done();
});
});
it.only('test errorLogger', function(done) {
var app = express();
var output = st();
app.use(app.router);
app.use(bunyanLogger.errorLogger({
stream: output
}));
app.get('/', function(req, res) {
throw new Error();
});
it('test errorLogger', function(done) {
var app = express();
app.use(app.router);
app.use(bunyanLogger.errorLogger());
request(app)
.get('/')
.end(function(err, res) {
var json = JSON.parse(output.content.toString());
assert.equal(json.name, 'express');
assert.equal(json.url, '/');
console.log(json);
assert.equal(json['status-code'], 500);
assert(json.res && json.req && json.err);
done();
});
});
app.get('/', function(req, res) {
throw new Error();
});
it('errorLogger should call next error middleware', function(done) {
var middlewareCalled = false;
var app = express();
app.use(app.router);
app.use(bunyanLogger.errorLogger());
app.use(function (err, req, res, next) {
middlewareCalled = true;
next(err);
});
request(app)
.get('/')
.end(function(err, res) {
done();
});
app.get('/', function(req, res) {
throw new Error();
});
request(app)
.get('/')
.expect(function () {
if (!middlewareCalled) {
throw new Error('middleware was not called');
}
})
.end(done);
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc