mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Merge pull request #2976 from shoma/fix-debug-logging-doc
Fix api doc of debug logging for Python 3
This commit is contained in:
+6
-3
@@ -184,11 +184,14 @@ API Changes
|
||||
import requests
|
||||
import logging
|
||||
|
||||
# these two lines enable debugging at httplib level (requests->urllib3->httplib)
|
||||
# Enabling debugging at http.client 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.
|
||||
import httplib
|
||||
httplib.HTTPConnection.debuglevel = 1
|
||||
try: # for Python 3
|
||||
from http.client import HTTPConnection
|
||||
except ImportError:
|
||||
from httplib import HTTPConnection
|
||||
HTTPConnection.debuglevel = 1
|
||||
|
||||
logging.basicConfig() # you need to initialize logging, otherwise you will not see anything from requests
|
||||
logging.getLogger().setLevel(logging.DEBUG)
|
||||
|
||||
Reference in New Issue
Block a user