Переделал нахуй всё
This commit is contained in:
36
utils/LogCon.py
Normal file
36
utils/LogCon.py
Normal 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)
|
||||
Reference in New Issue
Block a user