Add goroutine numbers to log lines

This commit is contained in:
2025-03-27 19:19:39 +01:00
parent e847e5c3ce
commit 66bcf21d79
4 changed files with 201 additions and 11 deletions

19
main.go
View File

@@ -184,31 +184,32 @@ func main() {
// Process each file
for _, file := range files {
wg.Add(1)
go func(file string) {
logger.SafeGoWithArgs(func(args ...interface{}) {
defer wg.Done()
logger.Debug("Processing file: %s", file)
fileToProcess := args[0].(string)
logger.Debug("Processing file: %s", fileToProcess)
// It's a bit fucked, maybe I could do better to call it from proc... But it'll do for now
modCount, matchCount, err := processor.Process(proc, file, pattern, luaExpr)
modCount, matchCount, err := processor.Process(proc, fileToProcess, pattern, luaExpr)
if err != nil {
logger.Error("Failed to process file %s: %v", file, err)
fmt.Fprintf(os.Stderr, "Failed to process file %s: %v\n", file, err)
logger.Error("Failed to process file %s: %v", fileToProcess, err)
fmt.Fprintf(os.Stderr, "Failed to process file %s: %v\n", fileToProcess, err)
stats.FailedFiles++
} else {
if modCount > 0 {
logger.Info("Successfully processed file %s: %d modifications from %d matches",
file, modCount, matchCount)
fileToProcess, modCount, matchCount)
} else if matchCount > 0 {
logger.Info("Found %d matches in file %s but made no modifications",
matchCount, file)
matchCount, fileToProcess)
} else {
logger.Debug("No matches found in file: %s", file)
logger.Debug("No matches found in file: %s", fileToProcess)
}
stats.ProcessedFiles++
stats.TotalMatches += matchCount
stats.TotalModifications += modCount
}
}(file)
}, file)
}
wg.Wait()