[logger] 规范统一输出

This commit is contained in:
wuko233 2026-04-04 07:13:07 +08:00
parent 99eb6c2aed
commit 6ea68852d1
2 changed files with 4 additions and 4 deletions

View File

@ -42,7 +42,7 @@ func (w *Watcher) Start() {
for _, path := range paths { for _, path := range paths {
if _, err := os.Stat(path); os.IsNotExist(err) { if _, err := os.Stat(path); os.IsNotExist(err) {
fmt.Printf("[monitor] 路径不存在: %s\n", path) logger.Log.Warn("[monitor] 路径不存在", zap.String("path", path))
continue continue
} }
@ -72,7 +72,7 @@ func (w *Watcher) eventLoop() {
if !ok { if !ok {
return return
} }
fmt.Printf("[monitor] 监听错误: %v\n", err) logger.Log.Error("[monitor] 监听错误", zap.Error(err))
case event, ok := <-w.fsnWatcher.Events: case event, ok := <-w.fsnWatcher.Events:
if !ok { if !ok {
return return
@ -121,7 +121,7 @@ func (w *Watcher) addPath(path string) {
} }
if err := w.fsnWatcher.Add(subPath); err != nil { 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))
} }
} }

View File

@ -63,7 +63,7 @@ func (s *Scanner) Scan() ([]FileInfo, error) {
progressbar.OptionShowIts(), progressbar.OptionShowIts(),
progressbar.OptionSetItsString("files"), progressbar.OptionSetItsString("files"),
progressbar.OptionOnCompletion(func() { progressbar.OptionOnCompletion(func() {
fmt.Fprintln(os.Stderr, "\n[scan]文件哈希计算完成") logger.Log.Info("[scan]文件哈希计算完成")
}), }),
) )