[chore] - lower logging level (#2249)

* lower logging level

* move pid len check outside loop
This commit is contained in:
ahrav 2023-12-20 09:50:32 -08:00 committed by GitHub
parent 4a66dddd81
commit 28212c9a82
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -63,6 +63,11 @@ func CleanTempArtifacts(ctx logContext.Context) error {
}
}
if len(pids) == 0 {
ctx.Logger().V(5).Info("No trufflehog processes were found")
return nil
}
tempDir := os.TempDir()
artifacts, err := os.ReadDir(tempDir)
if err != nil {
@ -70,10 +75,6 @@ func CleanTempArtifacts(ctx logContext.Context) error {
}
for _, artifact := range artifacts {
if len(pids) == 0 {
ctx.Logger().Info("No trufflehog processes were found")
continue
}
if trufflehogRE.MatchString(artifact.Name()) {
// Mark these artifacts initially as ones that should be deleted.
shouldDelete := true
@ -95,7 +96,7 @@ func CleanTempArtifacts(ctx logContext.Context) error {
err = os.Remove(artifactPath)
}
if err != nil {
return fmt.Errorf("Error deleting temp artifact: %s", artifactPath)
return fmt.Errorf("error deleting temp artifact: %s", artifactPath)
}
ctx.Logger().Info("Deleted orphaned temp artifact", "artifact", artifactPath)