Skip to content

Commit

Permalink
Merge pull request #1302 from ssbarnea/master
Browse files Browse the repository at this point in the history
Documents the actual logging methods #1297
  • Loading branch information
Kenneth Reitz committed Apr 14, 2013
2 parents 082029f + fb49481 commit 9df4501
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ pylint.txt
toy.py
violations.pyflakes.txt
cover/
build/
docs/_build
requests.egg-info/
*.pyc
*.swp
*.egg
env/

.workon
Expand Down
20 changes: 17 additions & 3 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,23 @@ API Changes

::

# Verbosity should now be configured with logging
my_config = {'verbose': sys.stderr}
requests.get('http://httpbin.org/headers', config=my_config) # bad!
import requests
import logging

# these two lines enable debugging at httplib level (requests->urllib3->httplib)
# 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
logging.basicConfig() # you need to initialize logging, otherwise you will not see anything from requests
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
requests.get('http://httpbin.org/headers')



Licensing
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
package_dir={'requests': 'requests'},
include_package_data=True,
install_requires=requires,
setup_requires=['sphinx'],
license=open('LICENSE').read(),
zip_safe=False,
classifiers=(
Expand Down

0 comments on commit 9df4501

Please sign in to comment.