-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.py
56 lines (42 loc) · 1.63 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from colorama import Fore, Back, Style, init
import sys
from datetime import datetime as dt
init()
class Logger:
def __init__(self,master):
self.master = master
def debug(self,*text,end='\n'):
print(Style.BRIGHT+Fore.BLUE+"["+self.time()+"] [&] "+str(self.master)+": ",end='')
for value in text:
print(value,end=' ')
print(Style.RESET_ALL,end=end)
def info(self,*text,end='\n'):
print(Style.BRIGHT+Fore.GREEN+"["+self.time()+"] [+] "+str(self.master)+": ",end='')
for value in text:
print(value,end=' ')
print(Style.RESET_ALL,end=end)
def warning(self,*text,end='\n'):
print(Style.BRIGHT+Fore.YELLOW+"["+self.time()+"] [*] "+str(self.master)+": ",end='')
for value in text:
print(value,end=' ')
print(Style.RESET_ALL,end=end)
def error(self,*text,end='\n'):
print(Style.BRIGHT+Fore.RED+"["+self.time()+"] [!] "+str(self.master)+": ",end='')
for value in text:
print(value,end=' ')
print(Style.RESET_ALL,end=end)
def critical(self,*text,end='\n'):
print(Style.BRIGHT+Fore.RED+"["+self.time()+"] [-] "+str(self.master)+": ",end='')
for value in text:
print(value,end=' ')
print(Style.RESET_ALL,end=end)
def time(self):
date = dt.now()
return date.strftime("%d/%m/%Y %H:%M:%S")
if __name__ == '__main__':
log = Logger("Test")
log.debug("Debug message")
log.info("Info message")
log.warning("Warning message")
log.error("Error message")
log.critical("Critical message")