update staticmethod to Log
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user