From: Ben Darnell Date: Sat, 24 Jan 2015 22:14:20 +0000 (-0500) Subject: Give curl_httpclient its own logger for its verbose debug output. X-Git-Tag: v4.1.0b1~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bff8603dcec9614f4ede78121eb647d80d1287ea;p=thirdparty%2Ftornado.git Give curl_httpclient its own logger for its verbose debug output. 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. --- diff --git a/tornado/curl_httpclient.py b/tornado/curl_httpclient.py index 68047cc94..ebbe0e84b 100644 --- a/tornado/curl_httpclient.py +++ b/tornado/curl_httpclient.py @@ -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):