Created
January 18, 2017 00:06
-
-
Save selbyk/9fec0e69e50f38e02ebd40792fb87cb6 to your computer and use it in GitHub Desktop.
log all node.js http/https requests
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
let reqCount = 0; | |
function requestLogger(httpModule) { | |
var original = httpModule.request; | |
httpModule.request = function(options, callback) { | |
console.log(reqCount++, options.method, options.href || options.proto + "://" + options.host + options.path); | |
console.log(options.uri); | |
console.log(options.headers); | |
return original(options, callback); | |
} | |
} | |
requestLogger(require('http')); | |
requestLogger(require('https')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment