2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 06:47:20 +08:00
Files
panel/internal/biz/log.go
Copilot 4f19a58bba feat: add date selector for viewing archived panel logs (#1316)
* 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>
2026-02-03 00:04:43 +08:00

55 lines
1.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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)
}