Fix up the logs a little

This commit is contained in:
2025-03-27 23:35:39 +01:00
parent 5d10178bf9
commit ba7ac07001
4 changed files with 78 additions and 7 deletions

View File

@@ -160,3 +160,12 @@ func LoadCommandFromArgs(args []string) ([]ModifyCommand, error) {
func LoadCommandsFromCookFiles(s string) ([]ModifyCommand, error) {
return nil, nil
}
// CountGlobsBeforeDedup counts the total number of glob patterns across all commands before deduplication
func CountGlobsBeforeDedup(commands []ModifyCommand) int {
count := 0
for _, cmd := range commands {
count += len(cmd.Files)
}
return count
}

View File

@@ -18,18 +18,18 @@ func ExecuteModifications(modifications []ReplaceCommand, fileData string) (stri
sort.Slice(modifications, func(i, j int) bool {
return modifications[i].From > modifications[j].From
})
logger.Trace("Applying %d replacement commands in reverse order", len(modifications))
logger.Trace("Preparing to apply %d replacement commands in reverse order", len(modifications))
executed := 0
for _, modification := range modifications {
fileData, err = modification.Execute(fileData)
if err != nil {
logger.Error("Failed to execute modification: %v", err)
logger.Error("Failed to execute replacement: %v", err)
continue
}
executed++
}
logger.Info("Executed %d modifications", executed)
logger.Info("Successfully applied %d text replacements", executed)
return fileData, executed
}