From c99d4f8a565de44793930d9f9d142e4a79c061ca Mon Sep 17 00:00:00 2001 From: UltraQbik Date: Wed, 28 Aug 2024 20:24:15 +0300 Subject: Fixed logging and added LOGGER_PATH into config.py --- main.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'main.py') diff --git a/main.py b/main.py index ae8f19a..3a14ff2 100644 --- a/main.py +++ b/main.py @@ -19,20 +19,20 @@ from src.status_code import * _usocket = socket.socket | ssl.SSLSocket # logging -if not os.path.exists("logs"): - os.mkdir("logs") -if os.path.isfile("logs/latest.log"): +if not os.path.exists(f"{LOGGER_PATH}"): + os.makedirs(f"{LOGGER_PATH}") +if os.path.isfile(f"{LOGGER_PATH}/latest.log"): import gzip from datetime import datetime - with open("logs/latest.log", "rb") as file: - with gzip.open(f"{datetime.now().strftime('%d-%m-%y %H-%M-%S')}.log.gz", "wb") as comp: + with open(f"{LOGGER_PATH}/latest.log", "rb") as file: + with gzip.open(f"{LOGGER_PATH}/{datetime.now().strftime('%d-%m-%y %H-%M-%S')}.log.gz", "wb") as comp: comp.writelines(file) - os.remove("logs/latest.log") + os.remove(f"{LOGGER_PATH}/latest.log") logging.basicConfig( level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s", handlers=[ - logging.FileHandler("logs/latest.log"), + logging.FileHandler(f"{LOGGER_PATH}/latest.log"), logging.StreamHandler() ] ) -- cgit 1.4.1