feat: add a service for periodic cleanup of error accounts based on configuration.
This commit is contained in:
@@ -89,13 +89,10 @@ func checkAndCleanErrors() {
|
||||
}
|
||||
|
||||
if len(errorAccounts) == 0 {
|
||||
logger.Info("没有错误账号需要清理", "", "cleaner")
|
||||
lastCleanTime = time.Now()
|
||||
return
|
||||
}
|
||||
|
||||
logger.Info(fmt.Sprintf("找到 %d 个错误账号,开始删除...", len(errorAccounts)), "", "cleaner")
|
||||
|
||||
success := 0
|
||||
failed := 0
|
||||
|
||||
@@ -106,7 +103,6 @@ func checkAndCleanErrors() {
|
||||
logger.Warning(fmt.Sprintf("删除账号失败: ID=%d, Email=%s, Error=%v", account.ID, account.Email, err), account.Email, "cleaner")
|
||||
} else {
|
||||
success++
|
||||
logger.Success(fmt.Sprintf("删除账号成功: ID=%d, Email=%s", account.ID, account.Email), account.Email, "cleaner")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -242,3 +242,22 @@ func ClearLogs() {
|
||||
defer logsMu.Unlock()
|
||||
logs = make([]LogEntry, 0, 1000)
|
||||
}
|
||||
|
||||
// ClearLogsByModule 按模块清除日志
|
||||
func ClearLogsByModule(module string) int {
|
||||
logsMu.Lock()
|
||||
defer logsMu.Unlock()
|
||||
|
||||
// 过滤掉指定模块的日志
|
||||
var newLogs []LogEntry
|
||||
cleared := 0
|
||||
for _, log := range logs {
|
||||
if log.Module != module {
|
||||
newLogs = append(newLogs, log)
|
||||
} else {
|
||||
cleared++
|
||||
}
|
||||
}
|
||||
logs = newLogs
|
||||
return cleared
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user