物联网软件

This commit is contained in:
BBIT-Kai
2026-02-04 14:02:57 +08:00
parent 646e312a4c
commit 1c11f3f06c
28 changed files with 4526 additions and 271 deletions
+14 -1
View File
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path/filepath"
"sentinel/pkg/config"
"time"
)
@@ -17,7 +18,14 @@ func Init(dir string) {
if err := os.MkdirAll(logDir, 0755); err != nil {
fmt.Println("create log dir failed:", err)
}
cleanupOldLogs()
go func() {
ticker := time.NewTicker(config.LOG_CHECK_INTERVAL_HOURS * time.Hour)
defer ticker.Stop()
for range ticker.C {
cleanupOldLogs()
}
}()
}
// Cleanup 删除超过7天的日志文件
@@ -73,6 +81,11 @@ func Println(v ...interface{}) {
msg := fmt.Sprint(v...)
logToFile("INFO", msg)
}
func Debug(v ...interface{}) {
//msg := fmt.Sprint(v...)
//logToFile("DEBUF", msg)
}
func Warn(msg string) {
logToFile("WARN", msg)
}