2022-12-14 17:49:29 -05:00
|
|
|
import logging as logger
|
|
|
|
from pathlib import Path
|
2023-01-16 14:11:08 -05:00
|
|
|
import os
|
2022-12-14 17:49:29 -05:00
|
|
|
|
2023-01-16 14:11:08 -05:00
|
|
|
log_dir = (Path(__file__).parent.parent / 'logs').resolve()
|
|
|
|
log_file = (log_dir / 'hub.log').resolve()
|
|
|
|
try:
|
|
|
|
if not os.path.isfile(log_file):
|
2023-03-16 11:27:46 -04:00
|
|
|
if not os.path.exists(log_dir):
|
2023-02-22 22:45:33 -05:00
|
|
|
os.mkdir(log_dir)
|
2023-01-16 14:11:08 -05:00
|
|
|
with open(log_file, 'x'):
|
|
|
|
pass
|
|
|
|
logger.basicConfig(filename=log_file, format="%(asctime)s:%(levelname)s:{%(pathname)s:%(funcName)s:%(lineno)d} "
|
|
|
|
"- %(message)s", level=logger.DEBUG)
|
|
|
|
except IOError as err:
|
|
|
|
print(f'I/O exception: {err}')
|