Skip to content

Commit

Permalink
Print records sent to Odoo (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
bastjan authored Feb 2, 2024
1 parent 62d5209 commit 3c90f3e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"os"
"time"

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

// print the records to stdout for preview
for _, record := range records {
m, err := json.Marshal(record)
if err != nil {
// can't use the logger from the context here, since the required context key is in the main package 🙃
// TODO(bastjan) fix the suboptimal and overcomplicated logging setup
fmt.Fprintf(os.Stderr, "warning: failed to marshal record for preview: %+v; error: %s\n", record, err)
continue
}
fmt.Fprintf(os.Stdout, "%s\n", m)
}

return multierr.Append(errs, odooClient.SendData(ctx, records))
}

Expand Down

0 comments on commit 3c90f3e

Please sign in to comment.