From d8db4634232f1849edede1e0e08ee29b2e9e9d3d Mon Sep 17 00:00:00 2001 From: croneter Date: Mon, 18 Oct 2021 09:05:48 +0200 Subject: [PATCH] Improve logging for http client --- resources/lib/plexbmchelper/listener.py | 10 ++++++---- resources/lib/plexbmchelper/plexgdm.py | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/resources/lib/plexbmchelper/listener.py b/resources/lib/plexbmchelper/listener.py index 329b053f..2da964a6 100644 --- a/resources/lib/plexbmchelper/listener.py +++ b/resources/lib/plexbmchelper/listener.py @@ -62,6 +62,7 @@ class MyHandler(BaseHTTPRequestHandler): self.answer_request(1) def do_OPTIONS(self): + LOG.debug("Serving OPTIONS request...") self.send_response(200) self.send_header('Content-Length', '0') self.send_header('X-Plex-Client-Identifier', v.PKC_MACHINE_IDENTIFIER) @@ -92,8 +93,8 @@ class MyHandler(BaseHTTPRequestHandler): self.send_header('Connection', "close") self.end_headers() self.wfile.write(body.encode('utf-8')) - except Exception: - pass + except Exception as exc: + LOG.debug('Exception encountered while responding: %s', exc) def answer_request(self, send_data): self.serverlist = self.server.client.getServerList() @@ -106,10 +107,11 @@ class MyHandler(BaseHTTPRequestHandler): params = {} for key in paramarrays: params[key] = paramarrays[key][0] - LOG.debug("remote request_path: %s", request_path) + LOG.debug("remote request_path: %s, received from %s with headers: %s", + request_path, self.client_address, self.headers.items()) LOG.debug("params received from remote: %s", params) sub_mgr.update_command_id(self.headers.get( - 'X-Plex-Client-Identifier', self.client_address[0]), + 'X-Plex-Client-Identifier', self.client_address[0]), params.get('commandID')) if request_path == "version": self.response( diff --git a/resources/lib/plexbmchelper/plexgdm.py b/resources/lib/plexbmchelper/plexgdm.py index bbab06f1..857d985c 100644 --- a/resources/lib/plexbmchelper/plexgdm.py +++ b/resources/lib/plexbmchelper/plexgdm.py @@ -97,8 +97,8 @@ class plexgdm(object): % (self.client_header, self.client_data), self.client_register_group) log.debug('(Re-)registering PKC Plex Companion successful') - except Exception: - log.error("Unable to send registration message") + except Exception as exc: + log.error("Unable to send registration message. Error: %s", exc) def client_update(self): self.update_sock = socket.socket(socket.AF_INET,