summaryrefslogtreecommitdiff
path: root/internal/goprecords/report.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/goprecords/report.go')
-rw-r--r--internal/goprecords/report.go25
1 files changed, 20 insertions, 5 deletions
diff --git a/internal/goprecords/report.go b/internal/goprecords/report.go
index 6724c47..11c809a 100644
--- a/internal/goprecords/report.go
+++ b/internal/goprecords/report.go
@@ -62,9 +62,13 @@ func WriteReports(w io.Writer, aggregates *Aggregates, cfg ReportConfig) error {
return fmt.Errorf("Category %s only supports: Boots, Uptime, Score", cfg.Category)
}
if cfg.Category == CategoryHost {
- io.WriteString(w, NewHostReporter(aggregates, cfg.Limit, cfg.Metric, cfg.OutputFormat, 1).Report())
+ if err := writeReportString(w, NewHostReporter(aggregates, cfg.Limit, cfg.Metric, cfg.OutputFormat, 1).Report()); err != nil {
+ return err
+ }
} else {
- io.WriteString(w, NewReporter(aggregates, cfg.Category, cfg.Limit, cfg.Metric, cfg.OutputFormat, 1).Report())
+ if err := writeReportString(w, NewReporter(aggregates, cfg.Category, cfg.Limit, cfg.Metric, cfg.OutputFormat, 1).Report()); err != nil {
+ return err
+ }
}
return nil
}
@@ -82,15 +86,26 @@ func WriteReports(w io.Writer, aggregates *Aggregates, cfg ReportConfig) error {
continue
}
if c == CategoryHost {
- io.WriteString(w, NewHostReporter(aggregates, cfg.Limit, m, cfg.OutputFormat, headerIndent).Report())
+ if err := writeReportString(w, NewHostReporter(aggregates, cfg.Limit, m, cfg.OutputFormat, headerIndent).Report()); err != nil {
+ return err
+ }
} else {
- io.WriteString(w, NewReporter(aggregates, c, cfg.Limit, m, cfg.OutputFormat, headerIndent).Report())
+ if err := writeReportString(w, NewReporter(aggregates, c, cfg.Limit, m, cfg.OutputFormat, headerIndent).Report()); err != nil {
+ return err
+ }
+ }
+ if err := writeReportString(w, "\n"); err != nil {
+ return err
}
- io.WriteString(w, "\n")
}
return nil
}
+func writeReportString(w io.Writer, s string) error {
+ _, err := io.WriteString(w, s)
+ return err
+}
+
type Reporter interface {
Report() string
}