diff options
| author | UltraQbik <no1skill@yandex.ru> | 2024-08-28 20:24:15 +0300 |
|---|---|---|
| committer | UltraQbik <no1skill@yandex.ru> | 2024-08-28 20:24:15 +0300 |
| commit | c99d4f8a565de44793930d9f9d142e4a79c061ca (patch) | |
| tree | 9e7583119394769308209f68c34eedc56fc7a7c9 | |
| parent | 291266c79ff900f7faccb0061604136993c58e4e (diff) | |
| download | httpy-c99d4f8a565de44793930d9f9d142e4a79c061ca.tar.gz httpy-c99d4f8a565de44793930d9f9d142e4a79c061ca.zip | |
Fixed logging and added LOGGER_PATH into config.py
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | main.py | 14 | ||||
| -rw-r--r-- | src/config.py | 1 |
3 files changed, 9 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore index 30a88c1..93547eb 100644 --- a/.gitignore +++ b/.gitignore @@ -167,3 +167,4 @@ cython_debug/ /compress/ /fullchain.pem /privkey.pem +/logs/ 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() ] ) diff --git a/src/config.py b/src/config.py index fe28e6d..29b18e3 100644 --- a/src/config.py +++ b/src/config.py @@ -1,4 +1,5 @@ # generic +LOGGER_PATH = "logs" BUFFER_LENGTH = 65536 # 64 KiB BUFFER_MAX_SIZE = 2**30 * 0.5 # 512 MiB CLIENT_MAX_AMOUNT = 512 # max requests at once, after which the connections are dropped |