Skip to content

Instantly share code, notes, and snippets.

@mrlannigan
Created January 18, 2013 15:33
Show Gist options
  • Save mrlannigan/4565351 to your computer and use it in GitHub Desktop.
Save mrlannigan/4565351 to your computer and use it in GitHub Desktop.
Express.js Debug functions
//debug app use
var use = app.use;
app.use = function(func) {
var ofunc = func;
func = function() {
console.t.log(ofunc.toString());
ofunc.apply(this, arguments);
}
use.call(this, func);
}
app.use(function(req, res, next) {
//debug res.send
var end = res.end, json = res.json;
res.end = function() {
app.logger.debug('ran res.end');
console.trace();
end.apply(this, arguments);
}
//debug res.json
res.json = function() {
app.logger.debug('ran res.json');
console.trace();
json.apply(this, arguments);
}
next();
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment