Переделал нахуй всё

This commit is contained in:
2024-12-01 11:31:39 +03:00
parent 78a1dd3d62
commit c379759418
16 changed files with 702 additions and 272 deletions

36
utils/LogCon.py Normal file
View File

@@ -0,0 +1,36 @@
import logging
from logging.handlers import TimedRotatingFileHandler
import json
import os
def setup_logger():
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
handler = TimedRotatingFileHandler(
"logs/app.log",
when="midnight",
interval=1,
backupCount=7,
encoding='utf-8'
)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
handler.setFormatter(formatter)
logger.addHandler(handler)
return logger
def load_config(config_path='config/config.json'):
"""
Загрузка конфигурации из JSON файла.
"""
if not os.path.exists(config_path):
raise FileNotFoundError(f"Конфигурационный файл не найден: {config_path}")
with open(config_path, 'r') as file:
return json.load(file)