Skip to content

Commit b5e657f

Browse files
authored
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 da710cc.
1 parent b342c39 commit b5e657f

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

pkg/handlers/archive.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,22 +174,21 @@ func (h *archiveHandler) openArchive(
174174
// to handle nested archives or to continue processing based on the file's content and depth in the archive structure.
175175
func (h *archiveHandler) extractorHandler(dataOrErrChan chan DataOrErr) func(context.Context, archives.FileInfo) error {
176176
return func(ctx context.Context, file archives.FileInfo) error {
177+
if common.IsDone(ctx) {
178+
return ctx.Err()
179+
}
180+
177181
lCtx := logContext.WithValues(
178182
logContext.AddLogger(ctx),
179183
"filename", file.Name(),
180184
"size", file.Size(),
181185
)
182-
lCtx.Logger().V(3).Info("Handling extracted file.")
183186

184187
if file.IsDir() || file.LinkTarget != "" {
185-
lCtx.Logger().V(3).Info("skipping directory or symlink")
188+
lCtx.Logger().V(4).Info("skipping directory or symlink")
186189
return nil
187190
}
188191

189-
if common.IsDone(ctx) {
190-
return ctx.Err()
191-
}
192-
193192
depth := 0
194193
if ctxDepth, ok := ctx.Value(depthKey).(int); ok {
195194
depth = ctxDepth
@@ -243,7 +242,7 @@ func (h *archiveHandler) extractorHandler(dataOrErrChan chan DataOrErr) func(con
243242
h.metrics.incFilesProcessed()
244243
h.metrics.observeFileSize(fileSize)
245244

246-
lCtx.Logger().V(4).Info("Processed file successfully", "filename", file.Name(), "size", file.Size())
245+
lCtx.Logger().V(4).Info("Opened file successfully", "filename", file.Name(), "size", file.Size())
247246
return h.openArchive(lCtx, depth, rdr, dataOrErrChan)
248247
}
249248
}

pkg/sources/git/git.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,9 +1296,11 @@ func HandleBinary(
12961296
)
12971297
}
12981298

1299-
ctx.Logger().V(3).Info(
1300-
"HandleFile did not consume all stdout data; excess discarded",
1301-
"bytes_discarded", n)
1299+
if n > 0 {
1300+
ctx.Logger().V(3).Info(
1301+
"HandleFile did not consume all stdout data; excess discarded",
1302+
"bytes_discarded", n)
1303+
}
13021304

13031305
// Wait for the command to finish and handle any errors.
13041306
waitErr := cmd.Wait()

0 commit comments

Comments
 (0)