Files
thechart/src/init.py

31 lines
712 B
Python

import os
from logger import init_logger
from constants import LOG_PATH, LOG_CLEAR, LOG_LEVEL
if not os.path.exists(LOG_PATH):
try:
os.mkdir(LOG_PATH)
print(LOG_PATH)
except Exception as e:
print(e)
log_files = (
f"{LOG_PATH}/thechart.log",
f"{LOG_PATH}/thechart.warning.log",
f"{LOG_PATH}/thechart.error.log",
)
testing_mode = LOG_LEVEL == "DEBUG"
logger = init_logger(__name__, testing_mode=testing_mode)
if LOG_CLEAR == "True":
try:
for log_file in log_files:
if os.path.exists(log_file):
with open(log_file, "r+") as t:
t.truncate(0)
except Exception as e:
logger.error(e)
raise