From 2d4760f5edf5f3e407b0588ca882ef98cf92b186 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Tue, 30 Nov 2021 17:33:47 +0100 Subject: [PATCH] Minor improvement to logging output --- classes/logger.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/classes/logger.py b/classes/logger.py index b1e8f42..1e8f1d1 100644 --- a/classes/logger.py +++ b/classes/logger.py @@ -1,9 +1,18 @@ import logging +import threading + +from datetime import datetime class Logger: - def debug(self, message): - print(message) + @staticmethod + def _format(message: str, severity: str) -> str: + thread = threading.current_thread().name + datestr = str(datetime.now()) + return f"{datestr} - {thread} - {severity} - {message}" - def info(self, message): - print(message) \ No newline at end of file + def debug(self, message: str) -> None: + print(self.__class__()._format(message, "DEBUG")) + + def info(self, message: str) -> None: + print(self.__class__()._format(message, "INFO")) \ No newline at end of file