Skip to content

Commit 2079fd1

Browse files
Merge pull request #32 from appuio/local-backfill-changes
Improve progress reporting
2 parents 3c90f3e + 929c231 commit 2079fd1

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

pkg/report/report.go

-13
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7-
"os"
87
"time"
98

109
"github.com/appuio/appuio-reporting/pkg/odoo"
@@ -105,18 +104,6 @@ func runQuery(ctx context.Context, odooClient OdooClient, prom PromQuerier, args
105104
}
106105
}
107106

108-
// print the records to stdout for preview
109-
for _, record := range records {
110-
m, err := json.Marshal(record)
111-
if err != nil {
112-
// can't use the logger from the context here, since the required context key is in the main package 🙃
113-
// TODO(bastjan) fix the suboptimal and overcomplicated logging setup
114-
fmt.Fprintf(os.Stderr, "warning: failed to marshal record for preview: %+v; error: %s\n", record, err)
115-
continue
116-
}
117-
fmt.Fprintf(os.Stdout, "%s\n", m)
118-
}
119-
120107
return multierr.Append(errs, odooClient.SendData(ctx, records))
121108
}
122109

report_command.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package main
33
import (
44
"context"
55
"fmt"
6-
"os"
76
"time"
87

98
"github.com/appuio/appuio-reporting/pkg/odoo"
@@ -122,8 +121,11 @@ func (cmd *reportCommand) runReportRange(ctx context.Context, odooClient *odoo.O
122121

123122
started := time.Now()
124123
reporter := report.WithProgressReporter(func(p report.Progress) {
125-
fmt.Fprintf(os.Stderr, "Report %d, Current: %s [%s]\n",
126-
p.Count, p.Timestamp.Format(time.RFC3339), time.Since(started).Round(time.Second),
124+
log.Info("Progress report",
125+
"product", cmd.ReportArgs.ProductID,
126+
"reportIndex", p.Count,
127+
"timestamp", p.Timestamp.Format(time.RFC3339),
128+
"timeElapsed", time.Since(started).Round(time.Second),
127129
)
128130
})
129131

0 commit comments

Comments
 (0)