forked from cibere/discord-bot-made-with-no-communication
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.py
30 lines (27 loc) · 905 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
import datetime
import logging
import pathlib
import sys
from logging.handlers import TimedRotatingFileHandler
def init():
logginglevel = logging.INFO
dircheck = pathlib.Path.exists(pathlib.Path.cwd().joinpath('logs'))
if dircheck != True:
print('Making Log Directory...')
pathlib.Path.mkdir(pathlib.Path.cwd().joinpath('logs'))
logging.basicConfig(
level=logginglevel,
format='%(asctime)s [%(levelname)s] %(message)s',
datefmt='%m/%d/%Y %I:%M:%S %p',
handlers=[
logging.StreamHandler(sys.stdout),
TimedRotatingFileHandler(
pathlib.Path.as_posix(pathlib.Path.cwd().joinpath('logs')) + '/log',
'midnight',
atTime=datetime.datetime.min.time(),
backupCount=4,
encoding='utf-8',
utc=True,
),
],
)