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:
@@ -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'
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user