feat(logs): unify filtering across list and stats

Make runtime log queries support request correlation and date-range diagnostics with shared filtering semantics so the log page can use one consistent contract.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-21 22:11:41 +08:00
parent 204cb223a3
commit a27736a832
4 changed files with 446 additions and 132 deletions

View File

@@ -6,12 +6,18 @@ export interface Log {
level: 'debug' | 'info' | 'warning' | 'error'
type: 'agent' | 'system' | 'chat'
user_id: string | null
request_id: string | null
route: string | null
method: string | null
status_code: number | null
error_type: string | null
operation: string | null
message: string
source: string | null
details: string | null
duration_ms: string | null
created_at: string
updated_at: string
details: Record<string, unknown> | null
duration_ms: number | null
created_at: string | null
updated_at: string | null
}
export interface LogStats {
@@ -36,19 +42,27 @@ export interface LogQueryResult {
page_size: number
}
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
}
export const logApi = {
list: (params?: {
log_type?: string
level?: string
source?: string
page?: number
page_size?: number
}): Promise<AxiosResponse<LogQueryResult>> => {
list: (params?: LogQueryParams): Promise<AxiosResponse<LogQueryResult>> => {
return api.get('/api/logs', { params })
},
getStats: (hours?: number): Promise<AxiosResponse<LogStats>> => {
return api.get('/api/logs/stats', { params: { hours } })
getStats: (params?: LogQueryParams): Promise<AxiosResponse<LogStats>> => {
return api.get('/api/logs/stats', { params })
},
getRecent: (params?: {