* Documented the logging, requested in #1297
authorSorin Sbarnea <sorin.sbarnea@gmail.com>
Wed, 10 Apr 2013 15:15:28 +0000 (16:15 +0100)
committerSorin Sbarnea <sorin.sbarnea@gmail.com>
Wed, 10 Apr 2013 15:15:28 +0000 (16:15 +0100)
* Added build directory and *.egg to .gitignore
* Added sphinx as setup requirement in order to be able to build documentation with `pyhton setup.py build_sphinx`

modified:   .gitignore
modified:   docs/api.rst
modified:   setup.py

.gitignore
docs/api.rst
setup.py

index a88418d..e1ea2a6 100644 (file)
@@ -7,10 +7,12 @@ pylint.txt
 toy.py
 violations.pyflakes.txt
 cover/
+build/
 docs/_build
 requests.egg-info/
 *.pyc
 *.swp
+*.egg
 env/
 
 .workon
index 771d7a8..dce19d3 100644 (file)
@@ -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")
+      requests_log.setLevel(logging.DEBUG)
+      requests_log.propagate = True
+      
+      requests.get('http://httpbin.org/headers')
+
 
 
 Licensing
index 52dfe02..64e305b 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -39,6 +39,7 @@ setup(
     package_dir={'requests': 'requests'},
     include_package_data=True,
     install_requires=requires,
+    setup_requires=['sphinx'],
     license=open('LICENSE').read(),
     zip_safe=False,
     classifiers=(