From 10c33af1331b8a99fc4995f5640d5093b2f19ffe Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Wed, 8 Sep 2021 23:36:59 +0100 Subject: [PATCH] Logging improvements --- helpers/myradio_api.py | 3 +-- helpers/state_manager.py | 4 ++-- ui-templates/status.html | 2 +- websocket_server.py | 5 ++--- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/helpers/myradio_api.py b/helpers/myradio_api.py index 7cf1efd..02fde77 100644 --- a/helpers/myradio_api.py +++ b/helpers/myradio_api.py @@ -375,8 +375,7 @@ class MyRadioAPI: self._log("Ending tracklistitemid {}".format(tracklistitemid)) - result = self.api_call("/tracklistItem/{}/endtime".format(tracklistitemid), method="PUT") - print(result) + self.api_call("/tracklistItem/{}/endtime".format(tracklistitemid), method="PUT") def _log(self, text: str, level: int = INFO): self.logger.log.log(level, "MyRadio API: " + text) diff --git a/helpers/state_manager.py b/helpers/state_manager.py index fb45cb2..7c32a28 100644 --- a/helpers/state_manager.py +++ b/helpers/state_manager.py @@ -36,7 +36,7 @@ class StateManager: # Try creating the directory. os.mkdir(path_dir) except Exception: - print("Failed to create state directory.") + self._logException("Failed to create state directory.") return self.filepath = resolve_external_file_path("/state/" + name + ".json") @@ -48,7 +48,7 @@ class StateManager: # Try creating the file. open(self.filepath, "x") except Exception: - self._log("Failed to create state file.", CRITICAL) + self._logException("Failed to create state file.") return file_raw: str diff --git a/ui-templates/status.html b/ui-templates/status.html index a67f86e..17482b5 100644 --- a/ui-templates/status.html +++ b/ui-templates/status.html @@ -43,7 +43,7 @@ {% endfor %}
{% else %} -

RIP. Failed to get this.

+

Failed to get status from Player Channel. Channel may be busy or has failed.

{% endif %} {% endfor %} diff --git a/websocket_server.py b/websocket_server.py index 5be356d..6fe3741 100644 --- a/websocket_server.py +++ b/websocket_server.py @@ -59,7 +59,7 @@ class WebsocketServer: _exit(0) def __del__(self): - print("Deleting websocket server") + self.logger.log.info("Deleting websocket server") self.quit() async def websocket_handler(self, websocket, path): @@ -225,7 +225,6 @@ class WebsocketServer: continue command = message.split(":")[1] - # print("Websocket Out:", command) if command == "STATUS": try: message = message.split("OKAY:")[1] @@ -263,4 +262,4 @@ class WebsocketServer: if __name__ == "__main__": - print("Don't do this") + raise Exception("Don't run this file standalone.")