-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy path__init__.py
More file actions
48 lines (36 loc) · 980 Bytes
/
__init__.py
File metadata and controls
48 lines (36 loc) · 980 Bytes
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
import os
import platform
import sys
from loguru import logger
is_windows = platform.system() == "Windows"
null_output = f"{'nul' if is_windows else '/dev/null'} 2>&1"
def run(command: str, output_path: str = null_output):
return os.system(f"{command} > {output_path}")
if is_windows:
with logger.catch():
try:
import colorama
colorama.init()
except Exception as e:
logger.exception(e)
def clear():
os.system("cls")
else:
def clear():
os.system("clear")
logger.remove()
logger.add(
"./logs/info/{time:YYYY-MM-DD}.log",
format="[{time:HH:mm:ss}] [{level}]: {message}",
encoding="utf8",
level="INFO",
)
logger.add(
"./logs/errors/{time:YYYY-MM-DD}.log",
format="[{time:HH:mm:ss}] [{level}]: {message}",
backtrace=True,
diagnose=True,
encoding="utf8",
level="ERROR",
)
logger.add(sys.stdout, format="<lvl>[{level}] {message}</lvl>", level="INFO")