2026-01-08 11:46:34 +08:00
# Logging Capability Specification
## Overview
2026-01-13 19:45:05 +08:00
2026-01-08 11:46:34 +08:00
This specification defines the logging capability for the BLS Project Console, which allows the system to read log records from Redis queues and display them in the console interface.
## Requirements
### Requirement: Log Reading from Redis
2026-01-13 19:45:05 +08:00
2026-01-08 11:46:34 +08:00
The system SHALL read log records from a Redis queue.
#### Scenario: Reading logs from Redis queue
2026-01-13 19:45:05 +08:00
2026-01-08 11:46:34 +08:00
- **WHEN** the server starts
- **THEN** it SHALL establish a connection to the Redis queue
- **AND** it SHALL begin listening for new log records
- **AND** it SHALL store log records in memory for display
### Requirement: Log Display in Console
2026-01-13 19:45:05 +08:00
2026-01-08 11:46:34 +08:00
The system SHALL display log records in a user-friendly format.
#### Scenario: Displaying logs in the console
2026-01-13 19:45:05 +08:00
2026-01-08 11:46:34 +08:00
- **WHEN** a log record is received from Redis
- **THEN** it SHALL be added to the log list in the console
- **AND** it SHALL display the log timestamp, level, and message
- **AND** it SHALL support scrolling through historical logs
### Requirement: Log Filtering
2026-01-13 19:45:05 +08:00
2026-01-08 11:46:34 +08:00
The system SHALL allow users to filter logs by level and time range.
#### Scenario: Filtering logs by level
2026-01-13 19:45:05 +08:00
2026-01-08 11:46:34 +08:00
- **WHEN** the user selects a log level filter
- **THEN** only logs with the selected level SHALL be displayed
#### Scenario: Filtering logs by time range
2026-01-13 19:45:05 +08:00
2026-01-08 11:46:34 +08:00
- **WHEN** the user selects a time range
- **THEN** only logs within the specified range SHALL be displayed
### Requirement: Log Auto-Refresh
2026-01-13 19:45:05 +08:00
2026-01-08 11:46:34 +08:00
The system SHALL automatically refresh logs in real-time.
#### Scenario: Real-time log updates
2026-01-13 19:45:05 +08:00
2026-01-08 11:46:34 +08:00
- **WHEN** a new log is added to the Redis queue
- **THEN** it SHALL be automatically displayed in the console
- **AND** the console SHALL scroll to the latest log if the user is viewing the end
## Data Model
### Log Record
2026-01-13 19:45:05 +08:00
2026-01-08 11:46:34 +08:00
```json
{
"id": "string",
"timestamp": "ISO-8601 string",
"level": "string", // e.g., INFO, WARN, ERROR, DEBUG
"message": "string",
"metadata": "object" // optional additional data
}
```
## API Endpoints
### GET /api/logs
2026-01-13 19:45:05 +08:00
- **Description**: Get log records for a specific project
2026-01-08 11:46:34 +08:00
- **Query Parameters**:
2026-01-13 19:45:05 +08:00
- `projectName` : Project name (required)
- `limit` : Maximum number of logs to return (default: 200)
- **Response**:
```json
{
"logs": [
{
"id": "string",
"timestamp": "ISO-8601 string",
"level": "string",
"message": "string",
"metadata": "object"
}
],
"projectStatus": "在线|离线|null",
"heartbeat": {
"apiBaseUrl": "string",
"lastActiveAt": "number",
"isOnline": "boolean",
"ageMs": "number"
}
}
```
2026-01-08 11:46:34 +08:00
### GET /api/logs/live
2026-01-13 19:45:05 +08:00
2026-01-08 11:46:34 +08:00
- **Description**: Establish a WebSocket connection for real-time log updates
- **Response**: Continuous stream of log records