commitcloud: add config option that enables logging of requests

Summary:
add config option for very verbose output (print the requests)

this option is intended for troubleshooting

and it can greatly simplify troubleshooting

Reviewed By: StanislavGlebik

Differential Revision: D7572794

fbshipit-source-id: c0c5cfcc22ebc7799b02abd7bb08dc6a9bc4c6cd
This commit is contained in:
Liubov Dmitrieva 2018-04-11 05:08:31 -07:00 committed by Saurabh Singh
parent 9979530751
commit e745c7b870
2 changed files with 9 additions and 0 deletions

View File

@ -54,6 +54,9 @@
# update to a new revision if the current revision has been moved
updateonmove = true
# option to print requests to Commit Cloud web endpoint (in debug level)
debugrequests = true
"""
from __future__ import absolute_import

View File

@ -46,6 +46,9 @@ class HttpsCommitCloudService(baseservice.BaseService):
# optional, but needed for using a sandbox
self.certs = ui.config('commitcloud', 'certs')
# debug option
self.debugrequests = ui.config('commitcloud', 'debugrequests')
def getauthparams():
oauth = ui.configbool('commitcloud', 'oauth')
""" If OAuth authentication is enabled we require
@ -120,6 +123,9 @@ class HttpsCommitCloudService(baseservice.BaseService):
def _send(self, path, data):
e = None
rdata = None
# print all requests if debugrequests and debug are both on
if self.debugrequests:
self.ui.debug('%s\n' % json.dumps(data, indent=4))
if self._getheader('Content-Encoding') == 'gzip':
buffer = util.stringio()
with gzip.GzipFile(fileobj=buffer, mode='w') as compressed: