New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

express-request-logger

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-request-logger

Log anything you want per request

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
79
decreased by-35.77%
Maintainers
1
Weekly downloads
 
Created
Source

express-request-logger

An easy way to create a key/value pair list to be logged on each request in express.

Installation

$ cd /path/to/your/project
$ npm install express-request-logger

Usage

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.

Middleware Setup

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));

Middleware Usage

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.

Dependencies

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

Package last updated on 07 May 2012

Did you know?

Socket

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.

Install

Related posts

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