feat: integrate zerolog for structured logging and replace fmt with logger

This commit is contained in:
2025-01-21 23:33:14 -06:00
parent 0d8e8acf3a
commit 0ca2a9eeed
6 changed files with 59 additions and 17 deletions

View File

@@ -1,9 +1,9 @@
package disk
import (
"fmt"
"os"
"path/filepath"
"s1d3sw1ped/SteamCache2/steamcache/logger"
"s1d3sw1ped/SteamCache2/vfs"
"s1d3sw1ped/SteamCache2/vfs/vfserror"
"sync"
@@ -53,14 +53,14 @@ func NewSkipInit(root string, capacity int64) *DiskFS {
}
func (d *DiskFS) init() {
// fmt.Printf("DiskFS(%s, %s) init", d.root, units.HumanSize(float64(d.capacity)))
// logger.Logger.Info().Str("name", d.Name()).Str("root", d.root).Str("capacity", units.HumanSize(float64(d.capacity))).Msg("init")
tstart := time.Now()
d.walk(d.root)
d.sg.Wait()
fmt.Printf("DiskFS(%s, %s) init took %v", d.root, units.HumanSize(float64(d.capacity)), time.Since(tstart))
logger.Logger.Info().Str("name", d.Name()).Str("root", d.root).Str("capacity", units.HumanSize(float64(d.capacity))).Str("duration", time.Since(tstart).String()).Msg("init")
}
func (d *DiskFS) walk(path string) {
@@ -86,7 +86,7 @@ func (d *DiskFS) walk(path string) {
d.info[k] = vfs.NewFileInfoFromOS(info, k)
d.mu.Unlock()
// fmt.Printf("DiskFS(%s, %s) init: %s", d.root, units.HumanSize(float64(d.capacity)), npath)
// logger.Logger.Debug().Str("name", d.Name()).Str("root", d.root).Str("capacity", units.HumanSize(float64(d.capacity))).Str("path", npath).Msg("init")
return nil
})
}()