apache / openwhisk-client-js

JavaScript client library for the Apache OpenWhisk platform
https://openwhisk.apache.org/
Apache License 2.0
82 stars 53 forks source link

add debug calls? #120

Open starpit opened 6 years ago

starpit commented 6 years ago

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

jthomas commented 6 years ago

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?

starpit commented 6 years ago

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' ] }
jthomas commented 6 years ago

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

starpit commented 6 years ago

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