app=myapp deploy=production fn=requestLogger at=headers x-request-start=1366754359823 x-forwarded-proto=https x-forwarded-port=443 x-forwarded-for=65.121.23.138 user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31" host=someapp.herokuapp.com cookie=connect.sid=s%3AgeKWQa0hBB99DC.%2BEmzdVXGqCDoJ4JKZcdEgnZXcYFojVrPWgR231pCY1A connection=close accept-language=en-US,en;q=0.8 accept-encoding=gzip,deflate,sdch accept-charset=ISO-8859-1,utf-8;q=0.7,*;q=0.3 accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
app=myapp deploy=production fn=requestLogger at=base base=https://someapp.com
app=myapp deploy=production fn=requestLogger at=body body="{\"id\":\"24\",\"query\":\"27\"}"
/**
* Module dependencies
*/
var debug = require("debug")
, metric = require('metric-log');
/**
* Global context...somewhere NOT in this file
*/
metric.global_context(app: "myapp", deploy: ENV["DEPLOY"])
/**
* Log headers
*/
var headers = metric.context({fn: "requestLogger", at: "headers"});
/**
* Log req.base
*/
var base = metric.context({fn: "requestLogger", at: "base"});
/**
* Log req.body
*/
var body = metric.context({fn: "requestLogger", at: "body"});
/**
* Log process.env
*/
var env = metric.context({fn: "requestLogger", at: "env"});
/**
* Middleware to log basic parameters about the request.
*/
module.exports = function() {
return function requestLogger(req, res, next) {
headers(req.headers);
env(process.env);
base({base: req.base});
body(typeof req.body === "object" && req.body !=== {} ? req.body : {body: req.body});
next();
};
};
DEBUG=connect:something,fn=requestLogger