Message ID | 20230116195059.25744-5-daniel@braunwarth.dev |
---|---|
State | Accepted |
Delegated to: | Stefano Babic |
Headers | show |
Series | examples/client: Various improvements | expand |
> This patch maps the logging level used by SWUpdate to the logging levels > used by Python and logs them with the actual level. > Signed-off-by: Daniel Braunwarth <daniel@braunwarth.dev> Applied to swupdate, master, thanks ! Best regards, Stefano Babic
diff --git a/examples/client/swupdate_client.py b/examples/client/swupdate_client.py index 78e92f1..751a268 100755 --- a/examples/client/swupdate_client.py +++ b/examples/client/swupdate_client.py @@ -16,6 +16,14 @@ import requests import websockets +LOGGING_MAPPING = { + "3": logging.ERROR, + "4": logging.WARNING, + "6": logging.INFO, + "7": logging.DEBUG, +} + + class SWUpdater: """Python helper class for SWUpdate""" @@ -58,7 +66,10 @@ class SWUpdater: if data["type"] != "message": continue - self._logger.info(data["text"]) + self._logger.log( + LOGGING_MAPPING[data["level"]], + data["text"]) + if "SWUPDATE successful" in data["text"]: return True if "Installation failed" in data["text"]:
This patch maps the logging level used by SWUpdate to the logging levels used by Python and logs them with the actual level. Signed-off-by: Daniel Braunwarth <daniel@braunwarth.dev> --- examples/client/swupdate_client.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)