From 4170d218dc834f9b174019287320de64e596e54c Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Thu, 24 Oct 2024 09:46:17 -0700 Subject: [PATCH] fix(cloud): Quiet the HTTP server log (#163) --- streamer/proxy_node.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/streamer/proxy_node.py b/streamer/proxy_node.py index 4bc659f..fdbaf20 100644 --- a/streamer/proxy_node.py +++ b/streamer/proxy_node.py @@ -103,6 +103,22 @@ def __init__(self, rate_limiter: RateLimiter, *args, **kwargs): # members never get set. super().__init__(*args, **kwargs) + # NOTE: The default values here for log_request are taken from the base + # class, and not a design decision of ours. + def log_request(self, code: str = '-', size: str = '-') -> None: + """Override the request logging feature of the Python HTTP server.""" + try: + code_int = int(code) + except: + code_int = 0 + + if code_int >= 200 and code_int <= 299: + # Stub out log_request to avoid creating noise from the HTTP server when + # requests are successful. + return + + return super().log_request(code, size) + def do_PUT(self) -> None: """Handle the PUT requests coming from Shaka Packager."""