Enhance logging system documentation and default logger configuration

- Updated the logging documentation to reflect changes in the unified log message format, including the addition of pathname, line number, and function name for better traceability.
- Modified the `get_logger` function to set a default value for `component_name`, improving usability for users who may not specify a component name.
- Ensured consistency in the documentation regarding the parameters and their descriptions.

These updates improve the clarity and ease of use of the logging system, making it more accessible for developers.
This commit is contained in:
Vasily.onl
2025-06-06 21:07:52 +08:00
parent e147aa1873
commit 848119e2cb
2 changed files with 9 additions and 6 deletions

View File

@@ -30,7 +30,7 @@ import threading
# Lock for thread-safe logger configuration
_lock = threading.Lock()
def get_logger(component_name: str, log_level: str = "INFO",
def get_logger(component_name: str = "default_logger", log_level: str = "INFO",
verbose: Optional[bool] = None, clean_old_logs: bool = True,
max_log_files: int = 30) -> logging.Logger:
"""
@@ -39,7 +39,8 @@ def get_logger(component_name: str, log_level: str = "INFO",
This function is thread-safe and ensures that handlers are not duplicated.
Args:
component_name: Name of the component (e.g., 'bot_manager', 'data_collector')
component_name: Name of the component (e.g., 'bot_manager', 'data_collector').
Defaults to 'default_logger' if not provided.
log_level: Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
verbose: Enable console logging. If None, uses VERBOSE_LOGGING from .env
clean_old_logs: (Deprecated) This is now handled by max_log_files.
@@ -74,7 +75,7 @@ def get_logger(component_name: str, log_level: str = "INFO",
# Unified formatter
formatter = logging.Formatter(
'[%(asctime)s - %(levelname)s - %(message)s]',
'[%(asctime)s - %(levelname)s - %(pathname)s:%(lineno)d - %(funcName)s] - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S'
)