mirror of
https://github.com/internetarchive/warcprox.git
synced 2025-01-18 13:22:09 +01:00
early trace-level logging of the requestline
This commit is contained in:
parent
c0e6c219ca
commit
11e11f4e68
2
setup.py
2
setup.py
@ -51,7 +51,7 @@ except:
|
||||
|
||||
setuptools.setup(
|
||||
name='warcprox',
|
||||
version='2.1b1.dev73',
|
||||
version='2.1b1.dev74',
|
||||
description='WARC writing MITM HTTP/S proxy',
|
||||
url='https://github.com/internetarchive/warcprox',
|
||||
author='Noah Levitt',
|
||||
|
@ -92,8 +92,17 @@ class RequestBlockedByRule(Exception):
|
||||
def __str__(self):
|
||||
return "%s: %s" % (self.__class__.__name__, self.msg)
|
||||
|
||||
# logging level more fine-grained than logging.DEBUG==10
|
||||
# monkey-patch log level TRACE
|
||||
TRACE = 5
|
||||
import logging
|
||||
def _logging_trace(msg, *args, **kwargs):
|
||||
logging.root.trace(msg, *args, **kwargs)
|
||||
def _logger_trace(self, msg, *args, **kwargs):
|
||||
if self.isEnabledFor(TRACE):
|
||||
self._log(TRACE, msg, args, **kwargs)
|
||||
logging.trace = _logging_trace
|
||||
logging.Logger.trace = _logger_trace
|
||||
logging.addLevelName(TRACE, 'TRACE')
|
||||
|
||||
import warcprox.controller as controller
|
||||
import warcprox.playback as playback
|
||||
|
@ -6,7 +6,7 @@ calling ssl.wrap_socket() on the client connection; connects to remote
|
||||
configured
|
||||
|
||||
Copyright (C) 2012 Cygnos Corporation
|
||||
Copyright (C) 2013-2016 Internet Archive
|
||||
Copyright (C) 2013-2017 Internet Archive
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
@ -279,6 +279,9 @@ class MitmProxyHandler(http_server.BaseHTTPRequestHandler):
|
||||
server. Then it calls self.handle_one_request() again to handle the
|
||||
request intended for the remote server.
|
||||
'''
|
||||
self.logger.trace(
|
||||
'request from %s:%s: %s', self.client_address[0],
|
||||
self.client_address[1], self.requestline)
|
||||
self.is_connect = True
|
||||
try:
|
||||
self._determine_host_port()
|
||||
@ -322,6 +325,9 @@ class MitmProxyHandler(http_server.BaseHTTPRequestHandler):
|
||||
return result
|
||||
|
||||
def do_COMMAND(self):
|
||||
self.logger.trace(
|
||||
'request from %s:%s: %s', self.client_address[0],
|
||||
self.client_address[1], self.requestline)
|
||||
if self.is_connect:
|
||||
self.url = self._construct_tunneled_url()
|
||||
else:
|
||||
@ -402,7 +408,7 @@ class MitmProxyHandler(http_server.BaseHTTPRequestHandler):
|
||||
except socket.timeout as e:
|
||||
self.logger.warn(
|
||||
"%s proxying %s %s", repr(e), self.command, self.url)
|
||||
except BaseException as e:
|
||||
except Exception as e:
|
||||
self.logger.error(
|
||||
"%s proxying %s %s", repr(e), self.command, self.url,
|
||||
exc_info=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user