]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Give curl_httpclient its own logger for its verbose debug output.
authorBen Darnell <ben@bendarnell.com>
Sat, 24 Jan 2015 22:14:20 +0000 (17:14 -0500)
committerBen Darnell <ben@bendarnell.com>
Sat, 24 Jan 2015 22:14:20 +0000 (17:14 -0500)
This makes it easier to filter it separately.

This commit is an updated recreation of
https://github.com/SuminAndrew/tornado/commit/88809314e853fb69610cf44095612e78b0882c3e
to account for code movement.

Closes #1093.

tornado/curl_httpclient.py

index 68047cc94880560e21a6e36af0c1010948abe3f2..ebbe0e84b9300485d1acae2ed405b4cf512b0e21 100644 (file)
@@ -28,12 +28,12 @@ from io import BytesIO
 
 from tornado import httputil
 from tornado import ioloop
-from tornado.log import gen_log
 from tornado import stack_context
 
 from tornado.escape import utf8, native_str
 from tornado.httpclient import HTTPResponse, HTTPError, AsyncHTTPClient, main
 
+curl_log = logging.getLogger('tornado.curl_httpclient')
 
 class CurlAsyncHTTPClient(AsyncHTTPClient):
     def initialize(self, io_loop, max_clients=10, defaults=None):
@@ -257,7 +257,7 @@ class CurlAsyncHTTPClient(AsyncHTTPClient):
 
     def _curl_create(self):
         curl = pycurl.Curl()
-        if gen_log.isEnabledFor(logging.DEBUG):
+        if curl_log.isEnabledFor(logging.DEBUG):
             curl.setopt(pycurl.VERBOSE, 1)
             curl.setopt(pycurl.DEBUGFUNCTION, self._curl_debug)
         return curl
@@ -403,11 +403,11 @@ class CurlAsyncHTTPClient(AsyncHTTPClient):
                 raise ValueError("Unsupported auth_mode %s" % request.auth_mode)
 
             curl.setopt(pycurl.USERPWD, native_str(userpwd))
-            gen_log.debug("%s %s (username: %r)", request.method, request.url,
+            curl_log.debug("%s %s (username: %r)", request.method, request.url,
                           request.auth_username)
         else:
             curl.unsetopt(pycurl.USERPWD)
-            gen_log.debug("%s %s", request.method, request.url)
+            curl_log.debug("%s %s", request.method, request.url)
 
         if request.client_cert is not None:
             curl.setopt(pycurl.SSLCERT, request.client_cert)
@@ -448,12 +448,12 @@ class CurlAsyncHTTPClient(AsyncHTTPClient):
     def _curl_debug(self, debug_type, debug_msg):
         debug_types = ('I', '<', '>', '<', '>')
         if debug_type == 0:
-            gen_log.debug('%s', debug_msg.strip())
+            curl_log.debug('%s', debug_msg.strip())
         elif debug_type in (1, 2):
             for line in debug_msg.splitlines():
-                gen_log.debug('%s %s', debug_types[debug_type], line)
+                curl_log.debug('%s %s', debug_types[debug_type], line)
         elif debug_type == 4:
-            gen_log.debug('%s %r', debug_types[debug_type], debug_msg)
+            curl_log.debug('%s %r', debug_types[debug_type], debug_msg)
 
 
 class CurlError(HTTPError):