feat(日志): 实现定时日志清理功能并统一服务端口为19070

- 添加每小时定时清理项目控制台日志功能,保留最新1000条且不超过24小时
- 将所有服务端口统一调整为19070,包括后端API、Nginx配置和文档
- 优化前端日志显示,支持单行折叠和点击展开
- 更新相关测试用例和部署文档
This commit is contained in:
2026-01-22 14:06:44 +08:00
parent 4551ae5733
commit 240e708fbe
21 changed files with 472 additions and 211 deletions

View 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

View File

@@ -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

View 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`