Skip to content

Commit

Permalink
write report
Browse files Browse the repository at this point in the history
  • Loading branch information
simulot committed Jun 1, 2024
1 parent 26204a9 commit 31b32c3
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions helpers/fileevent/fileevents.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log/slog"
"strings"
"sync"
"sync/atomic"
)
Expand Down Expand Up @@ -124,9 +125,11 @@ func (r *Recorder) SetLogger(l *slog.Logger) {
}

func (r *Recorder) Report() {
r.log.Info("\nInput analysis:\n----------------------")
fmt.Println("\nInput analysis:")
fmt.Println("----------------------")
sb := strings.Builder{}

sb.WriteString("\n")
sb.WriteString("Input analysis:\n")
sb.WriteString("---------------\n")
for _, c := range []Code{
DiscoveredImage,
DiscoveredVideo,
Expand All @@ -137,12 +140,12 @@ func (r *Recorder) Report() {
AnalysisAssociatedMetadata,
AnalysisMissingAssociatedMetadata,
} {
r.log.Info(fmt.Sprintf("%-40s: %7d", c.String(), r.counts[c]))
fmt.Printf("%-40s: %7d\n", c.String(), r.counts[c])
sb.WriteString(fmt.Sprintf("%-40s: %7d\n", c.String(), r.counts[c]))
}
r.log.Info("\nUploading:\n----------")
fmt.Println("\nUploading:")
fmt.Println("----------")

sb.WriteString("\n")
sb.WriteString("Uploading:\n")
sb.WriteString("----------\n")
for _, c := range []Code{
Uploaded,
UploadServerError,
Expand All @@ -151,9 +154,11 @@ func (r *Recorder) Report() {
UploadServerDuplicate,
UploadServerBetter,
} {
r.log.Info(fmt.Sprintf("%-40s: %7d", c.String(), r.counts[c]))
fmt.Printf("%-40s: %7d\n", c.String(), r.counts[c])
sb.WriteString(fmt.Sprintf("%-40s: %7d\n", c.String(), r.counts[c]))
}

r.log.Info(sb.String())
fmt.Println(sb.String())
}

func (r *Recorder) GetCounts() []int64 {
Expand Down

0 comments on commit 31b32c3

Please sign in to comment.