feat(日志): 实现定时日志清理功能并统一服务端口为19070
- 添加每小时定时清理项目控制台日志功能,保留最新1000条且不超过24小时 - 将所有服务端口统一调整为19070,包括后端API、Nginx配置和文档 - 优化前端日志显示,支持单行折叠和点击展开 - 更新相关测试用例和部署文档
This commit is contained in:
16
openspec/changes/update-log-prune-schedule/proposal.md
Normal file
16
openspec/changes/update-log-prune-schedule/proposal.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Change: Update Log Prune Schedule
|
||||
|
||||
## Why
|
||||
|
||||
项目日志持续增长会造成Redis列表膨胀,影响读写性能,需要在服务端统一执行定时清理。
|
||||
|
||||
## What Changes
|
||||
|
||||
- 每小时整点检查 `项目心跳` 内的全部项目日志列表
|
||||
- 删除 `${projectName}_项目控制台` 中超过24小时的日志记录
|
||||
- 若日志数量超过1000条,按时间倒序保留最新1000条
|
||||
|
||||
## Impact
|
||||
|
||||
- Affected specs: specs/logging/spec.md
|
||||
- Affected code: src/backend/routes/logs.js, src/backend/server.js
|
||||
@@ -0,0 +1,20 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Scheduled Log Pruning
|
||||
The system SHALL prune each `${projectName}_项目控制台` log list once per hour.
|
||||
|
||||
#### Scenario: Hourly pruning of console logs
|
||||
- **WHEN** the server reaches the top of an hour
|
||||
- **THEN** it SHALL remove log records older than 24 hours
|
||||
- **AND** it SHALL keep only the latest 1000 log records by timestamp
|
||||
- **AND** the pruning operation SHALL explicitly sort records by timestamp to ensure correctness regardless of insertion order
|
||||
|
||||
### Requirement: Console Log Display
|
||||
The console UI SHALL display logs in a compact format.
|
||||
|
||||
#### Scenario: Log Message Truncation
|
||||
- **WHEN** a log message is displayed in the list
|
||||
- **THEN** it SHALL be restricted to a single line
|
||||
- **AND** overflow content SHALL be indicated with an ellipsis
|
||||
- **AND** clicking the message SHALL toggle expansion to show the full content
|
||||
- **AND** only one message SHALL be expanded at a time
|
||||
13
openspec/changes/update-log-prune-schedule/tasks.md
Normal file
13
openspec/changes/update-log-prune-schedule/tasks.md
Normal file
@@ -0,0 +1,13 @@
|
||||
## 1. OpenSpec
|
||||
|
||||
- [x] 1.1 Add logging spec delta for scheduled log pruning
|
||||
|
||||
## 2. Backend
|
||||
|
||||
- [x] 2.1 Implement hourly log pruning with 24h TTL and 1000 limit
|
||||
- [x] 2.2 Update scheduled pruning tests
|
||||
|
||||
## 3. Verify
|
||||
|
||||
- [x] 3.1 Run `npm run test`
|
||||
- [x] 3.2 Run `npm run lint`
|
||||
Reference in New Issue
Block a user