schon/evibes/utils/misc.py
Egor fureunoir Gorbunov 9898212855 Features: 1) Introduced LoggingError exception for invalid log level handling in log method; 2) Updated logging framework to dynamically initialize loggers using __name__ instead of hardcoded "django".
Fixes: 1) Fixed missing `exc_info` flag in critical and error logs to provide richer error context; 2) Addressed redundant code and unused imports in the logging logic for cleaner execution.

Extra: Refactored `LOGGING` configuration for improved readability and runtime adaptability; optimized related log-handling logic throughout the codebase.
2025-11-04 14:40:50 +03:00

24 lines
494 B
Python

from enum import Enum
from importlib import import_module
from typing import Any
def create_object(module_name: str, class_name: str, *args: list[Any], **kwargs: dict[Any, Any]) -> Any:
module = import_module(module_name)
cls = getattr(module, class_name)
return cls(*args, **kwargs)
class LoggingError(Exception):
pass
class LogLevel(Enum):
DEBUG = "debug"
INFO = "info"
WARNING = "warning"
ERROR = "error"
CRITICAL = "critical"
TRACE = "trace"