Files
PyPost/log/Logger.py

35 lines
1.3 KiB
Python

import time
import colorama
colorama.init(autoreset=True)
class Logger:
@staticmethod
def log_error(message: str) -> None:
now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
print(f"{colorama.Fore.RED}[ ERROR@{now} ]: {message}{colorama.Style.RESET_ALL}")
@staticmethod
def log_info(message: str) -> None:
now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
print(f"{colorama.Fore.CYAN}[ INFO@{now} ]: {message}{colorama.Style.RESET_ALL}")
@staticmethod
def log_debug(message: str) -> None:
now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
print(f"[ DEBUG@{now} ]: {message}")
@staticmethod
def log_warning(message: str) -> None:
now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
print(f"{colorama.Fore.YELLOW}[ WARNING@{now} ]: {message}{colorama.Style.RESET_ALL}")
# yes we seriously needed this
@staticmethod
def log_obfuscation_info(message: str ,isenabled: bool) -> None:
now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
if isenabled:
print(f"[ INFO@{now} ]: {colorama.Fore.GREEN}{message}{colorama.Style.RESET_ALL}")
else:
print(f"[ INFO@{now} ]: {colorama.Fore.RED}{message}{colorama.Style.RESET_ALL}")