Skip to content

Commit

Permalink
Use our logging for pycurl messages
Browse files Browse the repository at this point in the history
Reimplementation of Pavol's PR #110.
  • Loading branch information
mmilata committed Aug 5, 2015
1 parent 489a90b commit 932a361
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions osbs/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def __init__(self, url, method, data=None, kerberos_auth=False,
self.c.setopt(pycurl.URL, str(url))
self.c.setopt(pycurl.WRITEFUNCTION, self.response_buffer.write)
self.c.setopt(pycurl.HEADERFUNCTION, self.headers_buffer.write)
self.c.setopt(pycurl.DEBUGFUNCTION, self._curl_debug)
self.c.setopt(pycurl.SSL_VERIFYPEER, 1 if verify_ssl else 0)
self.c.setopt(pycurl.SSL_VERIFYHOST, 2 if verify_ssl else 0)
self.c.setopt(pycurl.VERBOSE, 1 if verbose else 0)
Expand Down Expand Up @@ -299,6 +300,22 @@ def _split_lines_from_chunks(chunks):
if pending is not None:
yield pending

def _curl_debug(self, debug_type, debug_msg):
try:
logger_name = {
pycurl.INFOTYPE_TEXT: 'curl',
pycurl.INFOTYPE_HEADER_IN: 'in',
pycurl.INFOTYPE_HEADER_OUT: 'out'
}[debug_type]
except KeyError:
return

curl_logger = logging.getLogger(__name__ + '.' + logger_name)
for line in debug_msg.splitlines():
if not line:
continue
curl_logger.debug(line)

@property
def encoding(self):
encoding = None
Expand Down

0 comments on commit 932a361

Please sign in to comment.