apache/openwhisk-client-js

add debug calls?

starpit opened this issue · 4 comments

would it make sense to sprinkle the code with debug calls? personally, i would find this helpful for debugging.

This is a good idea. The needle library uses the debug package for a similar purpose.
https://www.npmjs.com/package/debug

I've used the DEBUG=needle flag before to get more dump the request/responses to the console but it doesn't include everything.

Do we want to follow that approach?

yes. i think the main missing pieces from needle are the body of the request and of the response. needle also includes too much information generally (though sometimes the extra info helps). finally, if a program is using needle for more than one purpose, having the ability to log just our requests is helpful.

e.g. too much info, and yet too little:

  needle Got response 200 { 'x-backside-transport': 'OK OK',
  connection: 'close',
  'transfer-encoding': 'chunked',
  server: 'nginx',
  date: 'Tue, 26 Jun 2018 11:53:38 GMT',
  'content-type': 'application/json',
  'x-request-id': '...',
  'access-control-allow-origin': '*',
  'access-control-allow-headers': 'Authorization, Content-Type',
  ibm_cloud_functions: 'OpenWhisk',
  'x-global-transaction-id': '...',
  'set-cookie': 
   [ 'DPJSESSIONID=PBC5YS:...; Path=/; Domain=.openwhisk.ng.bluemix.net; Secure; HttpOnly' ] }

LGTM, do you want to open a PR around this?

yes, i'll try to get something in the next few days