import os from logger import init_logger from constants import LOG_PATH, LOG_CLEAR, LOG_LEVEL if not os.path.exists(LOG_PATH): os.mkdir(LOG_PATH) log_files = ( f"{LOG_PATH}/app.log", f"{LOG_PATH}/app.warning.log", f"{LOG_PATH}/app.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