from colorama import init, Fore, Back, Style
from threading import Lock
import datetime

init() # 初始化colorama
print_mutex = Lock()

def print_normal_msg(*args, **kwargs) :
    current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    print_mutex.acquire()
    print(current_time, *args, **kwargs, end='')
    print(Style.RESET_ALL)
    print_mutex.release()
     
def print_warning_msg(*args, **kwargs) :
    current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    print_mutex.acquire()
    print(current_time, Fore.LIGHTMAGENTA_EX, *args, **kwargs, end='')
    print(Style.RESET_ALL)
    print_mutex.release()

def print_inform_msg(*args, **kwargs) :
    current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    print_mutex.acquire()
    print(current_time, Fore.YELLOW, *args, **kwargs, end='')
    print(Style.RESET_ALL)
    print_mutex.release()

def print_error_msg(*args, **kwargs) :
    current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    print_mutex.acquire()
    print(current_time, Fore.RED, *args, **kwargs, end='')
    print(Style.RESET_ALL)
    print_mutex.release()

def print_debug_msg(*args, **kwargs) :
    current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    print_mutex.acquire()
    print(current_time, Fore.BLUE, *args, **kwargs, end='')
    print(Style.RESET_ALL)
    print_mutex.release()