From 6ea68852d110f0c1ef3836ecc381cbc4fdfac4c7 Mon Sep 17 00:00:00 2001 From: wuko233 Date: Sat, 4 Apr 2026 07:13:07 +0800 Subject: [PATCH] =?UTF-8?q?[logger]=20=E8=A7=84=E8=8C=83=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/monitor/watcher/watcher.go | 6 +++--- internal/scanner/file/scanner.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/monitor/watcher/watcher.go b/internal/monitor/watcher/watcher.go index 02e8fde..4ac29e2 100644 --- a/internal/monitor/watcher/watcher.go +++ b/internal/monitor/watcher/watcher.go @@ -42,7 +42,7 @@ func (w *Watcher) Start() { for _, path := range paths { if _, err := os.Stat(path); os.IsNotExist(err) { - fmt.Printf("[monitor] 路径不存在: %s\n", path) + logger.Log.Warn("[monitor] 路径不存在", zap.String("path", path)) continue } @@ -72,7 +72,7 @@ func (w *Watcher) eventLoop() { if !ok { return } - fmt.Printf("[monitor] 监听错误: %v\n", err) + logger.Log.Error("[monitor] 监听错误", zap.Error(err)) case event, ok := <-w.fsnWatcher.Events: if !ok { return @@ -121,7 +121,7 @@ func (w *Watcher) addPath(path string) { } if err := w.fsnWatcher.Add(subPath); err != nil { - fmt.Printf("[monitor] 添加监听失败: %s, 错误: %v\n", subPath, err) + logger.Log.Error("[monitor] 添加监听失败", zap.String("path", subPath), zap.Error(err)) } } diff --git a/internal/scanner/file/scanner.go b/internal/scanner/file/scanner.go index 68ed4f2..e220533 100644 --- a/internal/scanner/file/scanner.go +++ b/internal/scanner/file/scanner.go @@ -63,7 +63,7 @@ func (s *Scanner) Scan() ([]FileInfo, error) { progressbar.OptionShowIts(), progressbar.OptionSetItsString("files"), progressbar.OptionOnCompletion(func() { - fmt.Fprintln(os.Stderr, "\n[scan]文件哈希计算完成") + logger.Log.Info("[scan]文件哈希计算完成") }), )