Add Verbose log level between Info and Debug

Implemented full log level hierarchy: Fatal, Error, Warn, Info, Verbose, Debug.
- Verbose level (-v) shows detailed operations like file changes (M/A/D)
- Debug level (-vv) shows low-level tracing with caller info
- Quiet mode (-q) sets level to Error, suppressing Info messages
- Banner and summary output now use log levels for filtering
This commit is contained in:
2025-12-17 15:17:27 -08:00
parent 0e86562c09
commit 5523cb1595
7 changed files with 187 additions and 92 deletions

View File

@@ -149,7 +149,7 @@ func (mfa *CLIApp) freshenManifestOperation(ctx *cli.Context) error {
existingMtime := time.Unix(existing.Mtime.Seconds, int64(existing.Mtime.Nanos))
if existing.Size != info.Size() || !existingMtime.Equal(info.ModTime()) {
changed++
log.Debugf("M %s", relPath)
log.Verbosef("M %s", relPath)
entries = append(entries, &freshenEntry{
path: relPath,
size: info.Size(),
@@ -170,7 +170,7 @@ func (mfa *CLIApp) freshenManifestOperation(ctx *cli.Context) error {
delete(existingByPath, relPath)
} else {
added++
log.Debugf("A %s", relPath)
log.Verbosef("A %s", relPath)
entries = append(entries, &freshenEntry{
path: relPath,
size: info.Size(),
@@ -198,7 +198,7 @@ func (mfa *CLIApp) freshenManifestOperation(ctx *cli.Context) error {
// Remaining entries in existingByPath are removed files
removed = int64(len(existingByPath))
for path := range existingByPath {
log.Debugf("D %s", path)
log.Verbosef("D %s", path)
}
scanDuration := time.Since(startScan)
@@ -305,21 +305,19 @@ func (mfa *CLIApp) freshenManifestOperation(ctx *cli.Context) error {
}
// Print summary
if !ctx.Bool("quiet") {
totalDuration := time.Since(mfa.startupTime)
var hashRate float64
if hashedBytes > 0 {
hashDuration := time.Since(startHash)
hashRate = float64(hashedBytes) / hashDuration.Seconds() / 1e6
}
log.Infof("freshen complete: %d unchanged, %d changed, %d added, %d removed",
unchanged, changed, added, removed)
if filesToHash > 0 {
log.Infof("hashed %.1f MB in %.1fs (%.1f MB/s)",
float64(hashedBytes)/1e6, totalDuration.Seconds(), hashRate)
}
log.Infof("wrote %d files to %s", len(entries), manifestPath)
totalDuration := time.Since(mfa.startupTime)
var hashRate float64
if hashedBytes > 0 {
hashDuration := time.Since(startHash)
hashRate = float64(hashedBytes) / hashDuration.Seconds() / 1e6
}
log.Infof("freshen complete: %d unchanged, %d changed, %d added, %d removed",
unchanged, changed, added, removed)
if filesToHash > 0 {
log.Infof("hashed %.1f MB in %.1fs (%.1f MB/s)",
float64(hashedBytes)/1e6, totalDuration.Seconds(), hashRate)
}
log.Infof("wrote %d files to %s", len(entries), manifestPath)
return nil
}