New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

common-log-string

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

common-log-string

dead stupid function to generate a common-log-format-ish string from request & response objects

latest
Source
npmnpm
Version
0.4.0
Version published
Weekly downloads
1.1K
16.14%
Maintainers
1
Weekly downloads
 
Created
Source

common-log-string

Dead stupid function to generate a common-log-format-ish string from request & response objects. Not guaranteed to work with anything other than node-restify.

on npm Tests

I wrote this because I wanted something that didn't attempt to write things to a log file and could be plugged into restify as middleware. Sample output:

- - [12/Mar/2015:08:54:46 -0700] "GET /_monitor/ping HTTP/1.1" 200 6 "" "HTTPie/0.8.0"

How to use:

var restify = require('restify');
var logstring = require('common-log-string');

var server = restify.createServer();
server.on('after', request, response, route, error)
{
    var output = logstring(request, response);
    request.logger.info(output);
});

Order of fields:

  • client ip
  • client id as per RFC 1413; (unfilled)
  • userid as determined by http auth (unfilled by this implementation)
  • timestamp
  • http request line
  • response status code
  • length of response body, if available
  • referrer string, from request headers
  • user agent string, from request headers
  • accept string, from request headers
  • elapsed time in milliseconds

The second to last is non-standard but useful.

Options

You may optionally pass an options object as the third parameter to the function. One option is currently respected:

ipHeader: report the client IP from this header instead of the address of the remote socket. Useful if you wish to log X-Forwarded-For IPs instead of the IP of an intermediate proxy.

LICENSE

ISC.

Keywords

apache

FAQs

Package last updated on 22 May 2018

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