about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--main.py14
-rw-r--r--src/config.py1
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