From f0b6a5c6fe7205f337c9ff86649a21d42e066e81 Mon Sep 17 00:00:00 2001 From: hofee Date: Thu, 4 Sep 2025 14:14:49 +0800 Subject: [PATCH] update staticmethod to Log --- pyapp/utils/log.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pyapp/utils/log.py b/pyapp/utils/log.py index 09f1c22..7279108 100644 --- a/pyapp/utils/log.py +++ b/pyapp/utils/log.py @@ -13,22 +13,28 @@ class Log: LogType.TERMINATE: "\033[96m" } + @staticmethod def get_time(): return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + @staticmethod def blue(message): # blue print(f"\033[94m{message}\033[0m") + @staticmethod def red(message): # red print(f"\033[91m{message}\033[0m") + @staticmethod def yellow(message): # yellow print(f"\033[93m{message}\033[0m") + @staticmethod def green(message): # green print(f"\033[92m{message}\033[0m") + @staticmethod def log(message, log_type: str): time_str = Log.get_time() space = "" @@ -42,28 +48,36 @@ class Log: print (f"\033[1m\033[4m({time_str})\033[0m \033[1m{Log.TYPE_COLOR_MAP[log_type]}[{log_type.capitalize()}]\033[0m{space} {Log.TYPE_COLOR_MAP[log_type]}{formatted_message}\033[0m") status_manager.add_log(time_str, log_type, formatted_message) + @staticmethod def bold(message): print(f"\033[1m{message}\033[0m") + @staticmethod def underline(message): print(f"\033[4m{message}\033[0m") + @staticmethod def info(message): Log.log(message, LogType.INFO) + @staticmethod def error(message, terminate=False): Log.log(message, LogType.ERROR) if terminate: Log.terminate("Application Terminated.") + @staticmethod def warning(message): Log.log(message, LogType.WARNING) + @staticmethod def success(message): Log.log(message, LogType.SUCCESS) + @staticmethod def debug(message): Log.log(message, LogType.DEBUG) + @staticmethod def terminate(message): Log.log(message, LogType.TERMINATE) exit(1)