-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathlogg.py
More file actions
72 lines (57 loc) · 2.48 KB
/
Copy pathlogg.py
File metadata and controls
72 lines (57 loc) · 2.48 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import logging
import os
import time
from functools import partial
import datetime
from colorama import Fore, Style, init
import os
class InputFormatter:
def __init__(self):
self.prompt_color = "\033[38;5;120m>>\033[0m "
def format_input(self, prompt):
return f"{self.prompt_color}{prompt}"
class CustomLogger:
def __init__(self) -> None:
init(autoreset=True)
self.colors = {
"green": Fore.GREEN,
"red": Fore.RED,
"yellow": Fore.YELLOW,
"blue": Fore.BLUE,
"magenta": Fore.MAGENTA,
"cyan": Fore.CYAN,
"white": Fore.WHITE,
"black": Fore.BLACK,
"reset": Style.RESET_ALL,
"lightblack": Fore.LIGHTBLACK_EX,
"lightred": Fore.LIGHTRED_EX,
"lightgreen": Fore.LIGHTGREEN_EX,
"lightyellow": Fore.LIGHTYELLOW_EX,
"lightblue": Fore.LIGHTBLUE_EX,
"lightmagenta": Fore.LIGHTMAGENTA_EX,
"lightcyan": Fore.LIGHTCYAN_EX,
"lightwhite": Fore.LIGHTWHITE_EX,
"darkblue": Fore.BLUE
}
def log(self, level, color, message, obj=""):
print(f"{self.timestamp()} {color}{level} {self.colors['reset']}│ {self.colors['white']}{message}"
f" {self.colors['lightgreen']}[{obj}]{self.colors['reset'] if obj else ''}")
def clear(self):
os.system("cls" if os.name == "nt" else "clear")
def timestamp(self):
return f"{self.colors['lightblack']}[{datetime.datetime.now().strftime('%H:%M:%S')}] {self.colors['reset']}"
def purchased(self, message, obj=""):
self.log(f"{self.colors['green']}✔ PURCHASED", self.colors['green'], message, obj )
def promo(self, message, obj=""):
self.log(f"{self.colors['blue']}✦ PROMO", self.colors['blue'], message, obj)
def success(self, message, obj=""):
self.log(f"{self.colors['cyan']}✔ SUCCESS", self.colors['cyan'], message, obj)
def error(self, message, obj=""):
self.log(f"{self.colors['red']}✖ ERROR", self.colors['red'], message, obj)
def info(self, message, obj=""):
self.log(f"{self.colors['green']}ℹ INFO", self.colors['green'], message, obj)
def linked(self, message, obj=""):
self.log(f"{self.colors['lightyellow']}ℹ LINK", self.colors['lightyellow'], message, obj)
def input(self, prompt):
formatted_prompt = self.input_formatter.format_input(prompt)
return input(formatted_prompt)