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:
@@ -8,8 +8,8 @@ The TCP Dashboard project uses a unified logging system built on Python's standa
|
||||
- **Standardized & Simple**: Relies on standard Python `logging` handlers, making it robust and easy to maintain.
|
||||
- **Date-based Rotation**: Log files are automatically rotated daily at midnight by `TimedRotatingFileHandler`.
|
||||
- **Automatic Cleanup**: Log file retention is managed automatically based on the number of backup files to keep (`backupCount`), preventing excessive disk usage.
|
||||
- **Unified Format**: All log messages follow a consistent format: `[YYYY-MM-DD HH:MM:SS - LEVEL - message]`.
|
||||
- **Configurable Console Output**: Optional verbose console output for real-time monitoring, configurable via function arguments or environment variables.
|
||||
- **Unified Format**: All log messages follow a detailed, consistent format: `[YYYY-MM-DD HH:MM:SS - LEVEL - pathname:lineno - funcName] - message]`.
|
||||
- **Configurable Console Output**: Optional console output for real-time monitoring, configurable via function arguments or environment variables.
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -36,7 +36,7 @@ The `get_logger` function accepts the following parameters:
|
||||
|
||||
| Parameter | Type | Default | Description |
|
||||
|-------------------|---------------------|---------|-----------------------------------------------------------------------------|
|
||||
| `component_name` | `str` | - | Name of the component (e.g., `bot_manager`). Used for the logger name and directory. |
|
||||
| `component_name` | `str` | `default_logger` | Name of the component (e.g., `bot_manager`). Used for the logger name and directory. |
|
||||
| `log_level` | `str` | `INFO` | The minimum logging level to be processed (DEBUG, INFO, WARNING, ERROR, CRITICAL). |
|
||||
| `verbose` | `Optional[bool]` | `None` | If `True`, enables console logging. If `None`, uses `VERBOSE_LOGGING` or `LOG_TO_CONSOLE` from environment variables. |
|
||||
| `max_log_files` | `int` | `30` | The maximum number of backup log files to keep. The core of the log cleanup mechanism. |
|
||||
@@ -58,6 +58,8 @@ logs/
|
||||
├── data_collector/
|
||||
│ ├── data_collector.log
|
||||
│ └── data_collector.log.2023-11-15
|
||||
└── default_logger/
|
||||
└── default_logger.log
|
||||
└── test_component/
|
||||
└── test_component.log
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user