forked from Emmet-v15/pygame-multiplayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.py
36 lines (28 loc) · 942 Bytes
/
logger.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import colorama
disabled = False
class Logger:
def __init__(self, name):
self.name = name
def disable():
global disabled
disabled = True
def log(self, msg):
if disabled:
return
print(f"{colorama.Fore.GREEN}[INFO] {self.name}: {msg}{colorama.Fore.RESET}")
def warn(self, msg):
if disabled:
return
print(f"{colorama.Fore.YELLOW}[WARN] {self.name}: {msg}{colorama.Fore.RESET}")
def error(self, msg):
if disabled:
return
print(f"{colorama.Fore.RED}[ERROR] {self.name}: {msg}{colorama.Fore.RESET}")
def debug(self, msg):
if disabled:
return
print(f"{colorama.Fore.BLUE}[DEBUG] {self.name}: {msg}{colorama.Fore.RESET}")
def critical(self, msg):
if disabled:
return
print(f"{colorama.Fore.MAGENTA}[CRITICAL] {self.name}: {msg}{colorama.Fore.RESET}")