feat: add a service for periodic cleanup of error accounts based on configuration.
This commit is contained in:
@@ -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