mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 06:47:20 +08:00
* Initial plan * feat: add date selector for log viewing - Add date parameter to log list API - Add log dates listing API - Update frontend with date selector in all log views - Add translations for Date field Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com> * refactor: cache regex patterns to avoid recompilation overhead Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com> * refactor: use predefined regex constants instead of sync.Map Simplified the regex caching by using predefined package-level constants for the three log types (app, db, http) instead of sync.Map. Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com> * fix: lint --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com> Co-authored-by: 耗子 <haozi@loli.email>
55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
package biz
|
||
|
||
import (
|
||
"time"
|
||
)
|
||
|
||
const (
|
||
LogTypeApp = "app"
|
||
LogTypeDB = "db"
|
||
LogTypeHTTP = "http"
|
||
)
|
||
|
||
// 操作日志类型常量
|
||
const (
|
||
OperationTypePanel = "panel"
|
||
OperationTypeWebsite = "website"
|
||
OperationTypeDatabase = "database"
|
||
OperationTypeDatabaseUser = "database_user"
|
||
OperationTypeDatabaseServer = "database_server"
|
||
OperationTypeProject = "project"
|
||
OperationTypeCert = "cert"
|
||
OperationTypeFile = "file"
|
||
OperationTypeApp = "app"
|
||
OperationTypeCron = "cron"
|
||
OperationTypeBackup = "backup"
|
||
OperationTypeContainer = "container"
|
||
OperationTypeFirewall = "firewall"
|
||
OperationTypeSafe = "safe"
|
||
OperationTypeSSH = "ssh"
|
||
OperationTypeSetting = "setting"
|
||
OperationTypeMonitor = "monitor"
|
||
OperationTypeWebhook = "webhook"
|
||
OperationTypeUser = "user"
|
||
)
|
||
|
||
// LogEntry 日志条目
|
||
type LogEntry struct {
|
||
Time time.Time `json:"time"`
|
||
Level string `json:"level"`
|
||
Msg string `json:"msg"`
|
||
Type string `json:"type,omitempty"`
|
||
OperatorID uint `json:"operator_id,omitempty"`
|
||
OperatorName string `json:"operator_name,omitempty"`
|
||
Extra map[string]any `json:"extra,omitempty"`
|
||
}
|
||
|
||
// LogRepo 日志仓库接口
|
||
type LogRepo interface {
|
||
// List 获取日志列表
|
||
// date 格式为 YYYY-MM-DD,空字符串表示当天日志
|
||
List(logType string, limit int, date string) ([]LogEntry, error)
|
||
// ListDates 获取可用的日志日期列表
|
||
ListDates(logType string) ([]string, error)
|
||
}
|