-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogcfg.py
32 lines (24 loc) · 810 Bytes
/
logcfg.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
import sys
from datetime import datetime
from logging import *
name = datetime.utcnow().strftime("logs/%Y-%m-%d_%H-%M.log")
c_handler = StreamHandler(sys.stdout)
f_handler = FileHandler(name, 'w+', 'utf-8')
c_handler.setLevel(15)
f_handler.setLevel(5)
f_format = Formatter('%(asctime)s\t%(name)s\t%(levelname)s: %(message)s')
f_handler.setFormatter(f_format)
def gLogr(*names: str):
res = []
for name in names:
new_logger = getLogger(name)
if len(new_logger.handlers) < 2:
new_logger.setLevel(1)
new_logger.addHandler(f_handler)
new_logger.addHandler(c_handler)
res.append(new_logger)
if len(res) == 1:
return res[0]
return res
discord_client_logger = gLogr('guilded.client') # hidden by default?
__all__ = ["gLogr"]