diff --git a/configs/logging_dev.yaml b/configs/logging_dev.yaml deleted file mode 100644 index 9f15197..0000000 --- a/configs/logging_dev.yaml +++ /dev/null @@ -1,18 +0,0 @@ -version: 1 -disable_existing_loggers: false - -formatters: - dev_formatter: - format: "%(asctime)s | %(levelname)-7s | %(name)s | %(message)s" - datefmt: "%H:%M:%S" - -handlers: - console: - class: logging.StreamHandler - level: TRACE - formatter: dev_formatter - stream: ext://sys.stdout - -root: - level: TRACE - handlers: [console] diff --git a/configs/logging_prod.yaml b/configs/logging_prod.yaml deleted file mode 100644 index 56713e0..0000000 --- a/configs/logging_prod.yaml +++ /dev/null @@ -1,18 +0,0 @@ -version: 1 -disable_existing_loggers: false - -formatters: - prod_formatter: - format: "%(asctime)s | %(levelname)-7s | %(name)s | %(message)s" - datefmt: "%Y-%m-%d %H:%M:%S" - -handlers: - console: - class: logging.StreamHandler - level: INFO - formatter: prod_formatter - stream: ext://sys.stdout - -root: - level: INFO - handlers: [file] \ No newline at end of file diff --git a/configs/logging_test.yaml b/configs/logging_test.yaml deleted file mode 100644 index 564c98d..0000000 --- a/configs/logging_test.yaml +++ /dev/null @@ -1,18 +0,0 @@ -version: 1 -disable_existing_loggers: false - -formatters: - test_formatter: - format: "%(asctime)s | %(levelname)-7s | %(name)s | %(message)s" - datefmt: "%Y-%m-%d %H:%M:%S" - -handlers: - console: - class: logging.StreamHandler - level: DEBUG - formatter: test_formatter - stream: ext://sys.stdout - -root: - level: DEBUG - handlers: [file] \ No newline at end of file diff --git a/src/core/__init__.py b/src/core/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/core/logger.py b/src/core/logger.py deleted file mode 100644 index 21a6af9..0000000 --- a/src/core/logger.py +++ /dev/null @@ -1,47 +0,0 @@ -import logging -import logging.config -import os -import yaml -from pathlib import Path - -TRACE_LEVEL_NUM = 5 -logging.addLevelName(TRACE_LEVEL_NUM, "TRACE") - -def trace(self, message, *args, **kws): - """ - Trace для логирования - Args: - message (_type_): сообщение - """ - if self.isEnabledFor(TRACE_LEVEL_NUM): - self._log(TRACE_LEVEL_NUM, message, args, **kws) - -logging.Logger.trace = trace - -def setup_logging(): - """ - Сетапит логирование по конфигу - Папки конфига захардкодены внутри проекта - """ - env = os.getenv("ENVIRONMENT", "dev").lower() - root_dir = Path(__file__).resolve().parent.parent.parent # .parent.parent.parent -> AGENT (корень проекта) - config_path = root_dir / "configs" / f"logging_{env}.yaml" - - if config_path.exists(): - with open(config_path, "rt", encoding="utf-8") as f: - try: - config = yaml.safe_load(f) - logging.config.dictConfig(config) - logging.getLogger(__name__).info(f"Логирование настроено из: {config_path}") - except Exception as e: - print(f"Ошибка при парсинге {config_path}: {e}") - logging.basicConfig(level=logging.INFO) - else: - print(f"ВНИМАНИЕ: Конфиг {config_path} не найден. Базовая настройка (INFO).") - logging.basicConfig(level=logging.INFO) - - -setup_logging() - -def get_logger(name: str) -> logging.Logger: - return logging.getLogger(name) \ No newline at end of file