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

express-errorlog

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-errorlog - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

10

package.json
{
"name": "express-errorlog",
"description": "Error handling and logging for Express (4.x)",
"version": "1.0.4",
"version": "1.1.0",
"author": {

@@ -24,5 +24,5 @@ "name": "Pier Fumagalli",

"devDependencies": {
"chai": "^2.2.0",
"chai": "^3.5.0",
"express": "^4.12.3",
"grunt": "^0.4.5",
"grunt": "^1.0.1",
"grunt-simple-mocha": "^0.4.0",

@@ -32,5 +32,5 @@ "request": "^2.54.0"

"dependencies": {
"errorlog": "^1.0.2",
"statuses": "^1.2.1"
"errorlog": "^1.4.3",
"statuses": "^1.3.1"
}
}

@@ -232,2 +232,17 @@ Express Error Log

Wrapped logger
--------------
The wrapped `errorlog` instance also available as `log(...)`, for example:
```javascript
var errorlog = require('express-errorlog');
app.use(errorlog);
// Log something
errorlog.log.info('This is an info message');
```
Configuration

@@ -234,0 +249,0 @@ -------------

@@ -11,3 +11,3 @@ 'use strict';

// Return our handler...
return function handler(err, req, res, next) {
function handler(err, req, res, next) {
// By default, this is a 500

@@ -88,3 +88,3 @@ var status = 500;

args.unshift(format);
logger.apply(null, args);
logger.error.apply(null, args);

@@ -95,2 +95,5 @@ // Send back our response!

}
handler.log = logger;
return handler;
}

@@ -104,1 +107,2 @@

}
exports.log = handler.log;

@@ -19,3 +19,2 @@ var request = require('request');

error.details = { testname: 'test-9' };
error.extra = "this only gets logged!";
throw error;

@@ -26,4 +25,2 @@ });

var error = Error('exception message for test-0');
error.more1 = 'some more in test 0'
error.more2 = 'even more in test 0'
next({

@@ -38,5 +35,6 @@ status: 411,

var logmessage = null;
express.use(errorlog({ logger: function(message) {
var logwrapper = errorlog({ logger: function(message) {
logmessage = message;
}}));
}});
express.use(logwrapper);

@@ -53,3 +51,3 @@ express.use(function(err, req, res, next) {

before(function(done) {
server = express.listen(-1, '127.0.0.1', function(error) {
server = express.listen(0, '127.0.0.1', function(error) {
if (error) done(error);

@@ -82,3 +80,3 @@ var address = server.address();

});
expect(logmessage).to.equal('GET /test-1 (400) - Bad Request');
expect(logmessage).to.equal('ERROR - GET /test-1 (400) - Bad Request');

@@ -103,3 +101,3 @@ return done();

});
expect(logmessage).to.equal('GET /test-2 (499) - Unknown status 499');
expect(logmessage).to.equal('ERROR - GET /test-2 (499) - Unknown status 499');

@@ -124,3 +122,3 @@ return done();

});
expect(logmessage).to.equal('GET /test-3 (500) - Unknown status 999');
expect(logmessage).to.equal('ERROR - GET /test-3 (500) - Unknown status 999');

@@ -145,3 +143,3 @@ return done();

});
expect(logmessage).to.equal('GET /test-4 (401) - message for test-4');
expect(logmessage).to.equal('ERROR - GET /test-4 (401) - message for test-4');

@@ -167,3 +165,3 @@ return done();

});
expect(logmessage).to.equal('GET /test-5 (402) - Payment Required\n >>> {"testname":"test-5"}');
expect(logmessage).to.equal('ERROR - GET /test-5 (402) - Payment Required\n >>> {"testname":"test-5"}');

@@ -189,3 +187,3 @@ return done();

});
expect(logmessage).to.equal('GET /test-6 (403) - message for test-6\n >>> {"testname":"test-6"}');
expect(logmessage).to.equal('ERROR - GET /test-6 (403) - message for test-6\n >>> {"testname":"test-6"}');

@@ -211,3 +209,3 @@ return done();

});
expect(logmessage).to.equal('GET /test-7 (500) - message for test-7\n >>> {"testname":"test-7"}');
expect(logmessage).to.equal('ERROR - GET /test-7 (500) - message for test-7\n >>> {"testname":"test-7"}');

@@ -233,4 +231,4 @@ return done();

expect(logmessage).to.match(new RegExp(
'^GET /test-8 \\(500\\) - exception message for test-8' + '\n' +
' Error: exception message for test-8' + '\n' +
'^ERROR - GET /test-8 \\(500\\) - exception message for test-8' + '\n' +
' Error: exception message for test-8' + '\n' +
' at '));

@@ -258,6 +256,5 @@

expect(logmessage).to.match(new RegExp(
'^GET /test-9 \\(410\\) - exception message for test-9' + '\n' +
' >>> {"testname":"test-9"}' + '\n' +
' >>> {"extra":"this only gets logged!"}' + '\n' +
' Error: exception message for test-9' + '\n' +
'^ERROR - GET /test-9 \\(410\\) - exception message for test-9' + '\n' +
' >>> {"testname":"test-9"}' + '\n' +
' Error: exception message for test-9' + '\n' +
' at '));

@@ -285,6 +282,5 @@

expect(logmessage).to.match(new RegExp(
'^GET /test-0 \\(411\\) - message for test-0' + '\n' +
' >>> {"testname":"test-0"}' + '\n' +
' >>> {"more1":"some more in test 0","more2":"even more in test 0"}' + '\n' +
' Error: exception message for test-0' + '\n' +
'^ERROR - GET /test-0 \\(411\\) - message for test-0' + '\n' +
' >>> {"testname":"test-0"}' + '\n' +
' Error: exception message for test-0' + '\n' +
' at '));

@@ -298,2 +294,11 @@

});
it('should work expose the wrapped logger', function() {
logwrapper.log.info('This is a test');
expect(logmessage).to.equal(' INFO - This is a test');
logwrapper.log.warn('This is a test');
expect(logmessage).to.equal(' WARN - This is a test');
logwrapper.log.error('This is a test');
expect(logmessage).to.equal('ERROR - This is a test');
});
})
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