修改客户端日志为 slog

This commit is contained in:
dushixiang committed 2025-12-30 20:00:35 +08:00
1 parent a92833a5bd
commit 6c499e2464
13 files changed
+292 -168

No files matched your search

+14 -1
View File
@@ -5,12 +5,14 @@ import (
"fmt"
"log"
"os"
"path/filepath"
"runtime"
"strings"
"github.com/dushixiang/pika/pkg/agent/config"
"github.com/dushixiang/pika/pkg/agent/service"
"github.com/dushixiang/pika/pkg/agent/updater"
"github.com/dushixiang/pika/pkg/agent/utils"
"github.com/spf13/cobra"
)
@@ -463,7 +465,13 @@ func registerAgent(cmd *cobra.Command, args []string) {
APIKey: apiKey,
},
Agent: config.AgentConfig{
Name: name,
Name: name,
LogLevel: "info",
LogFile: getHomeLogPath(),
LogMaxSize: 100,
LogMaxBackups: 3,
LogMaxAge: 28,
LogCompress: true,
},
Collector: config.CollectorConfig{
Interval: 5,
@@ -516,6 +524,11 @@ func maskToken(token string) string {
return token[:4] + "****" + token[len(token)-4:]
}
func getHomeLogPath() string {
homeDir := utils.GetSafeHomeDir()
return filepath.Join(homeDir, ".pika", "logs", "agent.log")
}
// showInfo 显示配置信息
func showInfo(cmd *cobra.Command, args []string) {
// 加载配置