Logging improvements
This commit is contained in:
parent
8a66ad86e6
commit
10c33af133
4 changed files with 6 additions and 8 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
{% endfor %}
|
||||
<br>
|
||||
{% else %}
|
||||
<p>RIP. Failed to get this.</p>
|
||||
<p>Failed to get status from Player Channel. Channel may be busy or has failed.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
|
|
@ -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.")
|
||||
|
|
Loading…
Reference in a new issue