Add log system with three log types (agent/system/chat)
Implemented a complete log system for tracking:
- Agent logs:智能体调用
- System logs: 系统运行
- Chat logs: 问答对话
Backend:
- Log model with type, level, user_id, message, source, duration_ms
- LogService with methods for logging and querying
- API endpoints: GET /api/logs, GET /api/logs/stats, GET /api/logs/recent
Frontend:
- LogView.vue with filters, stats, pagination, auto-refresh
- log.ts API client with TypeScript interfaces
- Added "运行日志" nav item to sidebar
2026-03-21 11:58:51 +08:00
|
|
|
import api from './index'
|
|
|
|
|
import type { AxiosResponse } from 'axios'
|
|
|
|
|
|
|
|
|
|
export interface Log {
|
|
|
|
|
id: string
|
|
|
|
|
level: 'debug' | 'info' | 'warning' | 'error'
|
|
|
|
|
type: 'agent' | 'system' | 'chat'
|
|
|
|
|
user_id: string | null
|
2026-03-21 22:11:41 +08:00
|
|
|
request_id: string | null
|
|
|
|
|
route: string | null
|
|
|
|
|
method: string | null
|
|
|
|
|
status_code: number | null
|
|
|
|
|
error_type: string | null
|
|
|
|
|
operation: string | null
|
Add log system with three log types (agent/system/chat)
Implemented a complete log system for tracking:
- Agent logs:智能体调用
- System logs: 系统运行
- Chat logs: 问答对话
Backend:
- Log model with type, level, user_id, message, source, duration_ms
- LogService with methods for logging and querying
- API endpoints: GET /api/logs, GET /api/logs/stats, GET /api/logs/recent
Frontend:
- LogView.vue with filters, stats, pagination, auto-refresh
- log.ts API client with TypeScript interfaces
- Added "运行日志" nav item to sidebar
2026-03-21 11:58:51 +08:00
|
|
|
message: string
|
|
|
|
|
source: string | null
|
2026-03-21 22:11:41 +08:00
|
|
|
details: Record<string, unknown> | null
|
|
|
|
|
duration_ms: number | null
|
|
|
|
|
created_at: string | null
|
|
|
|
|
updated_at: string | null
|
Add log system with three log types (agent/system/chat)
Implemented a complete log system for tracking:
- Agent logs:智能体调用
- System logs: 系统运行
- Chat logs: 问答对话
Backend:
- Log model with type, level, user_id, message, source, duration_ms
- LogService with methods for logging and querying
- API endpoints: GET /api/logs, GET /api/logs/stats, GET /api/logs/recent
Frontend:
- LogView.vue with filters, stats, pagination, auto-refresh
- log.ts API client with TypeScript interfaces
- Added "运行日志" nav item to sidebar
2026-03-21 11:58:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface LogStats {
|
|
|
|
|
total: number
|
|
|
|
|
by_type: {
|
|
|
|
|
agent: number
|
|
|
|
|
system: number
|
|
|
|
|
chat: number
|
|
|
|
|
}
|
|
|
|
|
by_level: {
|
|
|
|
|
debug: number
|
|
|
|
|
info: number
|
|
|
|
|
warning: number
|
|
|
|
|
error: number
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface LogQueryResult {
|
|
|
|
|
logs: Log[]
|
|
|
|
|
total: number
|
|
|
|
|
page: number
|
|
|
|
|
page_size: number
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-21 22:11:41 +08:00
|
|
|
export interface LogQueryParams {
|
|
|
|
|
log_type?: string
|
|
|
|
|
level?: string
|
|
|
|
|
source?: string
|
|
|
|
|
request_id?: string
|
|
|
|
|
route?: string
|
|
|
|
|
operation?: string
|
|
|
|
|
status_code?: number
|
|
|
|
|
start_at?: string
|
|
|
|
|
end_at?: string
|
|
|
|
|
page?: number
|
|
|
|
|
page_size?: number
|
|
|
|
|
}
|
|
|
|
|
|
Add log system with three log types (agent/system/chat)
Implemented a complete log system for tracking:
- Agent logs:智能体调用
- System logs: 系统运行
- Chat logs: 问答对话
Backend:
- Log model with type, level, user_id, message, source, duration_ms
- LogService with methods for logging and querying
- API endpoints: GET /api/logs, GET /api/logs/stats, GET /api/logs/recent
Frontend:
- LogView.vue with filters, stats, pagination, auto-refresh
- log.ts API client with TypeScript interfaces
- Added "运行日志" nav item to sidebar
2026-03-21 11:58:51 +08:00
|
|
|
export const logApi = {
|
2026-03-21 22:11:41 +08:00
|
|
|
list: (params?: LogQueryParams): Promise<AxiosResponse<LogQueryResult>> => {
|
Add log system with three log types (agent/system/chat)
Implemented a complete log system for tracking:
- Agent logs:智能体调用
- System logs: 系统运行
- Chat logs: 问答对话
Backend:
- Log model with type, level, user_id, message, source, duration_ms
- LogService with methods for logging and querying
- API endpoints: GET /api/logs, GET /api/logs/stats, GET /api/logs/recent
Frontend:
- LogView.vue with filters, stats, pagination, auto-refresh
- log.ts API client with TypeScript interfaces
- Added "运行日志" nav item to sidebar
2026-03-21 11:58:51 +08:00
|
|
|
return api.get('/api/logs', { params })
|
|
|
|
|
},
|
|
|
|
|
|
2026-03-21 22:11:41 +08:00
|
|
|
getStats: (params?: LogQueryParams): Promise<AxiosResponse<LogStats>> => {
|
|
|
|
|
return api.get('/api/logs/stats', { params })
|
Add log system with three log types (agent/system/chat)
Implemented a complete log system for tracking:
- Agent logs:智能体调用
- System logs: 系统运行
- Chat logs: 问答对话
Backend:
- Log model with type, level, user_id, message, source, duration_ms
- LogService with methods for logging and querying
- API endpoints: GET /api/logs, GET /api/logs/stats, GET /api/logs/recent
Frontend:
- LogView.vue with filters, stats, pagination, auto-refresh
- log.ts API client with TypeScript interfaces
- Added "运行日志" nav item to sidebar
2026-03-21 11:58:51 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getRecent: (params?: {
|
|
|
|
|
log_type?: string
|
|
|
|
|
hours?: number
|
|
|
|
|
limit?: number
|
|
|
|
|
}): Promise<AxiosResponse<Log[]>> => {
|
|
|
|
|
return api.get('/api/logs/recent', { params })
|
|
|
|
|
},
|
|
|
|
|
}
|