Skip to content

Instantly share code, notes, and snippets.

@PleahMaCaka
Created September 29, 2022 12:36
Show Gist options
  • Save PleahMaCaka/5b2c6e58c4a50cb3d23c9d3204c1540d to your computer and use it in GitHub Desktop.
Save PleahMaCaka/5b2c6e58c4a50cb3d23c9d3204c1540d to your computer and use it in GitHub Desktop.
import datetime as dt
class Color():
red = "\x1b[31m"
green = "\x1b[32m"
yellow = "\x1b[33m"
blue = "\x1b[34m"
white = "\x1b[37m"
bold = "\x1b[1m"
reset = "\x1b[0m"
class Logger():
isDebug = False
@staticmethod
def __get_date() -> str:
x = dt.datetime.now()
return f"[{str(x.year)[2:]}-{x.month}-{x.day} {x.hour}:{x.minute}:{x.second}] :: "
@staticmethod
def debug(content: str):
if Logger.isDebug:
print(Color.blue + Logger.__get_date() +
"[DEBUG] :: " + content + Color.reset)
else:
return
@staticmethod
def info(content: str):
print(Color.green + Logger.__get_date() +
"[INFO] :: " + content + Color.reset)
@staticmethod
def warn(content: str):
print(Color.yellow + Logger.__get_date() +
"[WARN] :: " + content + Color.reset)
@staticmethod
def error(content: str):
print(Color.red + Logger.__get_date() +
"[ERROR] :: " + content + Color.reset)
@staticmethod
def critical(content: str):
print(Color.red + Color.bold + Logger.__get_date() +
"[CRITICAL] :: " + content + Color.reset)
@staticmethod
def logger_test(msg: str):
Logger.info(msg)
Logger.isDebug = True
Logger.debug(msg)
Logger.isDebug = False
Logger.warn(msg)
Logger.error(msg)
Logger.critical(msg)
@PleahMaCaka
Copy link
Author

Hits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment