Improved logs for successful parses

This commit is contained in:
Simon Martens
2025-10-02 00:31:39 +02:00
parent 6dc9c997ad
commit 92ca4b3671
2 changed files with 15 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ import (
"sync"
"time"
"github.com/Theodor-Springmann-Stiftung/kgpz_web/helpers/logging"
"github.com/Theodor-Springmann-Stiftung/kgpz_web/providers/xmlprovider"
)
@@ -54,6 +55,12 @@ func (l *Library) Parse(source xmlprovider.ParseSource, baseDir, commit string)
l.mu.Lock()
defer l.mu.Unlock()
if commit != "" {
logging.Info("Parsing XML from commit: " + commit)
} else {
logging.Info("Parsing XML from directory: " + baseDir)
}
wg := sync.WaitGroup{}
meta := xmlprovider.ParseMeta{
Source: source,
@@ -142,6 +149,11 @@ func (l *Library) Parse(source xmlprovider.ParseSource, baseDir, commit string)
l.cleanup(meta)
l.Parses = append(l.Parses, meta)
// Log parsing statistics
logging.Info(fmt.Sprintf("Parse complete: %d agents, %d places, %d works, %d categories, %d issues, %d pieces",
len(l.Agents.Array), len(l.Places.Array), len(l.Works.Array),
len(l.Categories.Array), len(l.Issues.Array), len(l.Pieces.Array)))
var errors []string
if len(meta.FailedPaths) > 0 {
errors = append(errors, fmt.Sprintf("Failed paths: %v", meta.FailedPaths))