update staticmethod to Log
This commit is contained in:
@@ -13,22 +13,28 @@ class Log:
|
|||||||
LogType.TERMINATE: "\033[96m"
|
LogType.TERMINATE: "\033[96m"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
def get_time():
|
def get_time():
|
||||||
return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
def blue(message):
|
def blue(message):
|
||||||
# blue
|
# blue
|
||||||
print(f"\033[94m{message}\033[0m")
|
print(f"\033[94m{message}\033[0m")
|
||||||
|
@staticmethod
|
||||||
def red(message):
|
def red(message):
|
||||||
# red
|
# red
|
||||||
print(f"\033[91m{message}\033[0m")
|
print(f"\033[91m{message}\033[0m")
|
||||||
|
@staticmethod
|
||||||
def yellow(message):
|
def yellow(message):
|
||||||
# yellow
|
# yellow
|
||||||
print(f"\033[93m{message}\033[0m")
|
print(f"\033[93m{message}\033[0m")
|
||||||
|
@staticmethod
|
||||||
def green(message):
|
def green(message):
|
||||||
# green
|
# green
|
||||||
print(f"\033[92m{message}\033[0m")
|
print(f"\033[92m{message}\033[0m")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
def log(message, log_type: str):
|
def log(message, log_type: str):
|
||||||
time_str = Log.get_time()
|
time_str = Log.get_time()
|
||||||
space = ""
|
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")
|
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)
|
status_manager.add_log(time_str, log_type, formatted_message)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
def bold(message):
|
def bold(message):
|
||||||
print(f"\033[1m{message}\033[0m")
|
print(f"\033[1m{message}\033[0m")
|
||||||
|
@staticmethod
|
||||||
def underline(message):
|
def underline(message):
|
||||||
print(f"\033[4m{message}\033[0m")
|
print(f"\033[4m{message}\033[0m")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
def info(message):
|
def info(message):
|
||||||
Log.log(message, LogType.INFO)
|
Log.log(message, LogType.INFO)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
def error(message, terminate=False):
|
def error(message, terminate=False):
|
||||||
Log.log(message, LogType.ERROR)
|
Log.log(message, LogType.ERROR)
|
||||||
if terminate:
|
if terminate:
|
||||||
Log.terminate("Application Terminated.")
|
Log.terminate("Application Terminated.")
|
||||||
|
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
def warning(message):
|
def warning(message):
|
||||||
Log.log(message, LogType.WARNING)
|
Log.log(message, LogType.WARNING)
|
||||||
|
@staticmethod
|
||||||
def success(message):
|
def success(message):
|
||||||
Log.log(message, LogType.SUCCESS)
|
Log.log(message, LogType.SUCCESS)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
def debug(message):
|
def debug(message):
|
||||||
Log.log(message, LogType.DEBUG)
|
Log.log(message, LogType.DEBUG)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
def terminate(message):
|
def terminate(message):
|
||||||
Log.log(message, LogType.TERMINATE)
|
Log.log(message, LogType.TERMINATE)
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user