from os import _exit
from builtins import print as dprint

def print(text="", mode:str=None):
  color = "\033[0m"
  if mode:
    if mode[0] == "d":
      color = "\033[32m"
    elif mode[0] == "w":
      color = "\033[33m"
    elif mode[0] == "e":
      color = "\033[31m"
    elif mode[0] == "c":
      color = "\033[35m"
    else:
      color = "\033[36m"

  if isinstance(text, str):
    text = text.replace("<b>", "\033[1m").replace("</b>", "\033[22m")

  dprint(color+text+"\033[0m")

def debug(message:str):
  message = message.replace("<b>", "\033[1m").replace("</b>", "\033[22m")
  dprint("\033[32m"+message+"\033[0m")

def info(message:str):
  message = message.replace("<b>", "\033[1m").replace("</b>", "\033[22m")
  dprint("\033[36m"+message+"\033[0m")

def warning(message:str):
  message = message.replace("<b>", "\033[1m").replace("</b>", "\033[22m")
  dprint("\033[33m"+message+"\033[0m")

def error(message:str):
  message = message.replace("<b>", "\033[1m").replace("</b>", "\033[22m")
  dprint("\033[31m"+message+"\033[0m")

def critical(message:str, exit:int=1):
  message = message.replace("<b>", "\033[1m").replace("</b>", "\033[22m")
  dprint("\033[35m"+message+"\033[0m")
  if exit:
    _exit(exit)