Created
January 18, 2013 15:33
-
-
Save mrlannigan/4565351 to your computer and use it in GitHub Desktop.
Express.js Debug functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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