rveitch
2/1/2017 - 3:12 PM

log OUTGOING http/https requests from node

log OUTGOING http/https requests from node

//  install a hook on http/https requests

function requestLogger(httpModule){
    var original = httpModule.request
    httpModule.request = function(options, callback){
      console.log(options.href||options.proto+"://"+options.host+options.path, options.method)
      return original(options, callback)
    }
}

requestLogger(require('http'))
// requestLogger(require('https'))