Files
Web_BLS_ProjectConsole/openspec/specs/logging/spec.md
XuJiacheng 7ac3949dfa feat: 重构项目心跳为Redis LIST并更新相关文档
重构项目心跳数据结构为Redis LIST,更新相关文档和OpenSpec规范。主要变更包括:
- 将项目心跳从STRING改为LIST类型
- 更新后端服务以支持LIST操作
- 同步更新文档和OpenSpec规范
- 统一后端端口为3001
- 添加部署指南和Windows部署文档

修复前端API请求路径,移除硬编码的localhost地址。添加PM2和Nginx配置文件模板,完善部署流程文档。更新Redis集成协议文档,明确LIST数据结构和外部项目对接规范。
2026-01-17 18:36:52 +08:00

2.5 KiB

Logging Capability Specification

Overview

This specification defines the logging capability for the BLS Project Console, which allows the system to read log records from Redis lists and display them in the console interface.

Requirements

Requirement: Log Reading from Redis

The system SHALL read log records from a Redis LIST ${projectName}_项目控制台.

Scenario: Reading logs by polling

  • WHEN the user is viewing a project console
  • THEN the system SHALL read the latest log entries via LRANGE
  • AND it SHALL return logs in a user-friendly structure

Requirement: Log Display in Console

The system SHALL display log records in a user-friendly format.

Scenario: Displaying logs in the console

  • 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

The system SHALL allow users to filter logs by level and time range.

Scenario: Filtering logs by level

  • WHEN the user selects a log level filter
  • THEN only logs with the selected level SHALL be displayed

Scenario: Filtering logs by time range

  • WHEN the user selects a time range
  • THEN only logs within the specified range SHALL be displayed

Requirement: Log Auto-Refresh

The system SHALL automatically refresh logs in real-time.

Scenario: Real-time log updates

  • 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

{
  "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

  • Description: Get log records for a specific project
  • Query Parameters:
    • projectName: Project name (required)
    • limit: Maximum number of logs to return (default: 200)
  • Response:
    {
      "logs": [
        {
          "id": "string",
          "timestamp": "ISO-8601 string",
          "level": "string",
          "message": "string",
          "metadata": "object"
        }
      ],
      "projectStatus": "在线|离线|null",
      "heartbeat": {
        "apiBaseUrl": "string",
        "lastActiveAt": "number",
        "isOnline": "boolean",
        "ageMs": "number"
      }
    }