openwhisk-client-js icon indicating copy to clipboard operation
openwhisk-client-js copied to clipboard

add debug calls?

Open starpit opened this issue 7 years ago • 4 comments

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

starpit avatar Jun 25 '18 13:06 starpit

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?

jthomas avatar Jun 26 '18 07:06 jthomas

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' ] }

starpit avatar Jun 26 '18 11:06 starpit

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

jthomas avatar Jun 26 '18 15:06 jthomas

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

starpit avatar Jun 26 '18 15:06 starpit