Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
feat: integrate lumberjack for log file management, enhancing logging capabilities with rotation and compression
wizardchen4d244f51d27d
diff --git a/go.mod b/go.modindex 17ee9e7c8..f8e313d3c 100644--- a/go.mod+++ b/go.mod@@ -70,6 +70,7 @@ require (google.golang.org/api v0.259.0google.golang.org/grpc v1.78.0google.golang.org/protobuf v1.36.11+ gopkg.in/natefinch/lumberjack.v2 v2.2.1gopkg.in/yaml.v3 v3.0.1gorm.io/driver/postgres v1.5.11gorm.io/driver/sqlite v1.6.0@@ -308,7 +309,6 @@ require (google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirectgoogle.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b // indirectgopkg.in/inf.v0 v0.9.1 // indirect- gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirectgopkg.in/yaml.v2 v2.4.0 // indirectk8s.io/apimachinery v0.32.3 // indirectsigs.k8s.io/yaml v1.4.0 // indirectdiff --git a/internal/logger/logger.go b/internal/logger/logger.goindex a1ad7f4f9..884d07a4e 100644--- a/internal/logger/logger.go+++ b/internal/logger/logger.go@@ -14,6 +14,7 @@ import ("github.com/Tencent/WeKnora/internal/types""github.com/sirupsen/logrus"+ "gopkg.in/natefinch/lumberjack.v2")// appLogger 使用私有实例,避免外部依赖改写 logrus 全局状态导致日志丢失@@ -21,7 +22,7 @@ var appLogger = logrus.New()var (loggerMu sync.Mutex- activeLogFile *os.File+ activeLogFile io.WriteCloser)// LogLevel 日志级别类型@@ -262,14 +263,20 @@ func defaultMacAppLogPath() string {return filepath.Join(homeDir, "Library", "Logs", appName, appName+".log")}-func openLogFile(logPath string) (*os.File, error) {+func openLogFile(logPath string) (io.WriteCloser, error) {dir := filepath.Dir(logPath)if dir != "." {if err := os.MkdirAll(dir, 0o755); err != nil {return nil, err}}- return os.OpenFile(logPath, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o644)+ return &lumberjack.Logger{+ Filename: logPath,+ MaxSize: 50, // megabytes+ MaxBackups: 3,+ MaxAge: 28, // days+ Compress: true,+ }, nil}// 添加调用者字段