Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
express-request-logger
Advanced tools
An easy way to create a key/value pair list to be logged on each request in express.
$ cd /path/to/your/project
$ npm install express-request-logger
This package is meant to be used as middleware for a web app using Express. It will allow you to create a key/value pair list of data to get logged per request. Using this it can output data to allow you to analyze how your web app is being used.
Since response time is a part of the logging output, express-request-logger should be put as early in the middleware chain as possible.
var winston = require('winston');
var reqLogger = require('express-request-logger');
var logger = new (winston.Logger)({ transports: [ new (winston.transports.Console)() ] });
app.use(reqLogger.create(logger));
The req
object will now have a kvLog
object that can have extra data added to it. At the end of the request it will be logged with all the other data collected.
function (req, res, next) {
// ...
req.kvLog.action = 'test';
// ...
}
The key message
is special, it will be removed from the object and be sent to the logger as the true message. It is optional, so if it is not included, the log will just contain an empty message.
Currently it is recommended to use winston as the logger object, but any object that can be called like loggerObj.log(level, message, {key: value})
will work.
FAQs
Log anything you want per request
The npm package express-request-logger receives a total of 79 weekly downloads. As such, express-request-logger popularity was classified as not popular.
We found that express-request-logger demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.