Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions databricks_cli/click_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import click
from click import ParamType, Option, MissingParameter, UsageError


Expand Down Expand Up @@ -104,6 +105,22 @@ def __init__(self):
def set_debug(self, debug=False):
self._debug = debug

if not self._debug:
return

# These two lines enable debugging at httplib level (requests->urllib3->http.client)
# You will see the REQUEST, including HEADERS and DATA,
# and RESPONSE with HEADERS but without DATA.
# The only thing missing will be the response.body which is not logged.
try:
import http.client as http_client
except ImportError:
# Python 2
import httplib as http_client

click.echo("HTTP debugging enabled")
http_client.HTTPConnection.debuglevel = 1

@property
def debug_mode(self):
return self._debug
Expand Down