Socket
Socket
Sign inDemoInstall

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.3 to 1.0.4

2

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

@@ -6,0 +6,0 @@ "name": "Pier Fumagalli",

@@ -8,3 +8,3 @@ Express Error Log

* [Install and use](#install-and-use)
* [Logging and responses](#logging-and-responses)
* [Logging and sample JSON responses](#logging-and-sample-json-responses)
* [Numbers](#numbers)

@@ -29,3 +29,3 @@ * [Strings](#strings)

Then configure as the last route of your Express app:
Then configure as the last routes of your Express app:

@@ -35,9 +35,24 @@ ```javascript

app.use(errorlog);
// The error handler writing the response
app.use(function(err, req, res, next) {
res.json(err);
})
```
The `express-errorlog` handler will normalize whatever your application passed
to the `next(...)` function and log an error message.
It will then pass the normalized error to the next error handler, which will
have the job of rendering the actual response to the client.
Logging and responses
---------------------
The examples below assume that the final error handler will simply send back
a JSON of the normalized error (no need to set the status again,
`express-errorhandler` will set that for you already).
Logging and sample JSON responses
---------------------------------
In order to trigger log entries, simply use Express' own `next(...)` function,

@@ -230,3 +245,2 @@ passing one of the the following types of parameter:

logger: function/stream,
render: true/false
}));

@@ -241,4 +255,2 @@ ```

* `category`: a category name that will be inserted in the message to log.
* `render`: A _boolean_, if `true` the response will be sent to the client
using Express' own `render(...)` function (extra for `express-errorlog`).

@@ -245,0 +257,0 @@ As with [`errorlog`](https://www.npmjs.com/package/errorlog), use a package

@@ -9,3 +9,2 @@ 'use strict';

var logger = errorlog(options);
var render = options.render || false;

@@ -92,7 +91,4 @@ // Return our handler...

// Send back our response!
if (render) {
return res.status(status).render(response);
} else {
return res.status(status).json(response);
}
res.statusCode = status;
return next(response);
}

@@ -99,0 +95,0 @@ }

@@ -40,2 +40,6 @@ var request = require('request');

express.use(function(err, req, res, next) {
return res.json(err);
});
describe('Express Error Handler', function() {

@@ -42,0 +46,0 @@

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