Polish logging around git and archives to reduce noise (#4034)

* Polish logging around archives in git to reduce noise

* Log notable skipping at level 2

* Skipping based on extension happens a lot; bump the log level down to 3

* Bump empty reader log level back down to 5

* Put context check back where it was

* Revert "Put context check back where it was"

This reverts commit da710ccd16ad5504623129b6ad5589a43f218d1c.
This commit is contained in:
Charlie Gunyon
2025-04-22 12:40:04 +02:00
committed by GitHub
parent b342c395fc
commit b5e657fca6
2 changed files with 11 additions and 10 deletions
+6 -7
View File
@@ -174,22 +174,21 @@ func (h *archiveHandler) openArchive(
// to handle nested archives or to continue processing based on the file's content and depth in the archive structure.
func (h *archiveHandler) extractorHandler(dataOrErrChan chan DataOrErr) func(context.Context, archives.FileInfo) error {
return func(ctx context.Context, file archives.FileInfo) error {
if common.IsDone(ctx) {
return ctx.Err()
}
lCtx := logContext.WithValues(
logContext.AddLogger(ctx),
"filename", file.Name(),
"size", file.Size(),
)
lCtx.Logger().V(3).Info("Handling extracted file.")
if file.IsDir() || file.LinkTarget != "" {
lCtx.Logger().V(3).Info("skipping directory or symlink")
lCtx.Logger().V(4).Info("skipping directory or symlink")
return nil
}
if common.IsDone(ctx) {
return ctx.Err()
}
depth := 0
if ctxDepth, ok := ctx.Value(depthKey).(int); ok {
depth = ctxDepth
@@ -243,7 +242,7 @@ func (h *archiveHandler) extractorHandler(dataOrErrChan chan DataOrErr) func(con
h.metrics.incFilesProcessed()
h.metrics.observeFileSize(fileSize)
lCtx.Logger().V(4).Info("Processed file successfully", "filename", file.Name(), "size", file.Size())
lCtx.Logger().V(4).Info("Opened file successfully", "filename", file.Name(), "size", file.Size())
return h.openArchive(lCtx, depth, rdr, dataOrErrChan)
}
}
+5 -3
View File
@@ -1296,9 +1296,11 @@ func HandleBinary(
)
}
ctx.Logger().V(3).Info(
"HandleFile did not consume all stdout data; excess discarded",
"bytes_discarded", n)
if n > 0 {
ctx.Logger().V(3).Info(
"HandleFile did not consume all stdout data; excess discarded",
"bytes_discarded", n)
}
// Wait for the command to finish and handle any errors.
waitErr := cmd.Wait()