20 lines
423 B
Python
20 lines
423 B
Python
import sys
|
|
import threading
|
|
from datetime import datetime
|
|
|
|
_console_lock = threading.Lock()
|
|
|
|
def _log(prefix: str, message: str):
|
|
time = datetime.now().strftime("[%H:%M:%S]")
|
|
with _console_lock:
|
|
print(f"{time} {prefix} {message}")
|
|
|
|
def info(message: str):
|
|
_log("INFO", message)
|
|
|
|
def warning(message: str):
|
|
_log("WARNING", message)
|
|
|
|
def error(message: str):
|
|
_log("ERROR", message)
|
|
sys.exit(1) |