Skip to content

Commit

Permalink
feat: improve formatter cache debug logging
Browse files Browse the repository at this point in the history
Signed-off-by: Brian McGee <[email protected]>
  • Loading branch information
brianmcgee committed May 17, 2024
1 parent 54d3cd0 commit 385fbc3
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,23 @@ func Open(treeRoot string, clean bool, formatters map[string]*format.Formatter)
return fmt.Errorf("failed to retrieve cache entry for formatter %v: %w", name, err)
}

clean = clean || entry == nil || !(entry.Size == stat.Size() && entry.Modified == stat.ModTime())
logger.Debug(
"checking if formatter has changed",
"name", name,
"clean", clean,
"entry", entry,
"stat", stat,
)
isNew := entry == nil
hasChanged := entry != nil && !(entry.Size == stat.Size() && entry.Modified == stat.ModTime())

if isNew {
logger.Debugf("formatter '%s' is new", name)
} else if hasChanged {
logger.Debug("formatter '%s' has changed",
name,
"size", stat.Size(),
"modTime", stat.ModTime(),
"cachedSize", entry.Size,
"cachedModTime", entry.Modified,
)
}

// update overall clean flag
clean = clean || isNew || hasChanged

// record formatters info
entry = &Entry{
Expand Down

0 comments on commit 385fbc3

Please sign in to comment.