Browse Source

Properly log requests in SimpleHTTPRequestHandler

We use the SimpleHTTPRequestHandler as proxy in web urls test and as
fake gerrit server. By default it pollutes stderr with every request
it receives. This produces much visual noise when running tox. By
overriding the log_message method this can be logged properly.

Change-Id: Ifc5f1558dc374fa884fd5625221ba4089d533572
tags/3.6.0
Tobias Henkel 5 months ago
parent
commit
b3b4ab678b
No account linked to committer's email address
1 changed files with 8 additions and 0 deletions
  1. 8
    0
      tests/base.py

+ 8
- 0
tests/base.py View File

@@ -561,6 +561,9 @@ class GerritWebServer(object):
561 561
                 self.send_response(200)
562 562
                 self.end_headers()
563 563
 
564
+            def log_message(self, fmt, *args):
565
+                self.log.debug(fmt, *args)
566
+
564 567
         self.httpd = socketserver.ThreadingTCPServer(('', 0), Server)
565 568
         self.port = self.httpd.socket.getsockname()[1]
566 569
         self.thread = threading.Thread(name='GerritWebServer',
@@ -2064,6 +2067,8 @@ class WebProxyFixture(fixtures.Fixture):
2064 2067
         rules = self.rules
2065 2068
 
2066 2069
         class Proxy(http.server.SimpleHTTPRequestHandler):
2070
+            log = logging.getLogger('zuul.WebProxyFixture.Proxy')
2071
+
2067 2072
             def do_GET(self):
2068 2073
                 path = self.path
2069 2074
                 for (pattern, replace) in rules:
@@ -2078,6 +2083,9 @@ class WebProxyFixture(fixtures.Fixture):
2078 2083
                 self.end_headers()
2079 2084
                 self.wfile.write(resp.content)
2080 2085
 
2086
+            def log_message(self, fmt, *args):
2087
+                self.log.debug(fmt, *args)
2088
+
2081 2089
         self.httpd = socketserver.ThreadingTCPServer(('', 0), Proxy)
2082 2090
         self.port = self.httpd.socket.getsockname()[1]
2083 2091
         self.thread = threading.Thread(target=self.httpd.serve_forever)

Loading…
Cancel
Save