feat: Add a new cleaner page for managing and automatically cleaning error S2A accounts, supported by new backend services for logging, authentication, and client operations.
This commit is contained in:
@@ -332,7 +332,7 @@ func handleClearLogsByModule(w http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
}
|
||||
|
||||
// handleQueryLogs GET /api/logs/query?module=cleaner&page=1&page_size=5
|
||||
// handleQueryLogs GET /api/logs/query?module=cleaner&page=1&page_size=5&level=success
|
||||
func handleQueryLogs(w http.ResponseWriter, r *http.Request) {
|
||||
module := r.URL.Query().Get("module")
|
||||
if module == "" {
|
||||
@@ -342,6 +342,8 @@ func handleQueryLogs(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
page := 1
|
||||
pageSize := 5
|
||||
level := r.URL.Query().Get("level") // 可选的日志级别过滤
|
||||
|
||||
if v := r.URL.Query().Get("page"); v != "" {
|
||||
if p, err := strconv.Atoi(v); err == nil && p > 0 {
|
||||
page = p
|
||||
@@ -353,7 +355,14 @@ func handleQueryLogs(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
entries, total := logger.GetLogsByModule(module, page, pageSize)
|
||||
// 如果指定了 level,使用带级别过滤的函数
|
||||
var entries []logger.LogEntry
|
||||
var total int
|
||||
if level != "" {
|
||||
entries, total = logger.GetLogsByModuleAndLevel(module, level, page, pageSize)
|
||||
} else {
|
||||
entries, total = logger.GetLogsByModule(module, page, pageSize)
|
||||
}
|
||||
totalPages := (total + pageSize - 1) / pageSize
|
||||
|
||||
api.Success(w, map[string]interface{}{
|
||||
|
||||
Reference in New Issue
Block a user