Skip to content

Commit

Permalink
report: print header at the beginning of the output
Browse files Browse the repository at this point in the history
  • Loading branch information
lesovsky committed Oct 3, 2019
1 parent 77db2dd commit 5276228
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions doc/Changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
pgcenter (0.6.2) unstable; urgency=low
* report: print header at the beginning of the output
* top/report: refactoring aligning
* adjust header's styles of iostat/nicstat tabs in top utility
* added support for pg_stat_database.checksum_failures (pg-12)
* added support of pg_stat_progress_cluster and pg_stat_progress_create_index views
Expand Down
5 changes: 3 additions & 2 deletions report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func RunMain(args []string, opts ReportOptions) {
func doReport(r *tar.Reader, opts ReportOptions) error {
var prevStat, diffStat stat.PGresult
var prevTs time.Time
var linesPrinted int8
var linesPrinted int8 = repeatHeaderAfter // initial value means print header at the beginning of all output

// read files headers continuously, read stats files requested by user and skip others.
for {
Expand Down Expand Up @@ -159,7 +159,8 @@ func formatReport(d *stat.PGresult, opts *ReportOptions) {

// printStatHeader periodically prints names of stats columns
func printStatHeader(printedNum int8, cols []string, opts ReportOptions) int8 {
if printedNum >= repeatHeaderAfter {

if printedNum >= repeatHeaderAfter && opts.Context.Aligned {
fmt.Printf(" ")
for i, name := range cols {
fmt.Printf("\033[%d;%dm%-*s\033[0m", 37, 1, opts.Context.ColsWidth[i]+2, name)
Expand Down

0 comments on commit 5276228

Please sign in to comment.