Skip to content

Commit

Permalink
Fixed single process pretty printer bug.
Browse files Browse the repository at this point in the history
This PR fixes a bug where the single process deployer was using a
separate pretty printer for every component. This leads to bad
highlighting and tabularization. Now, every component shares a pretty
printer.
  • Loading branch information
mwhittaker committed May 31, 2023
1 parent ea2a43e commit e3bf5a2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions singleprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type singleprocessEnv struct {
submissionTime time.Time
statsProcessor *imetrics.StatsProcessor // tracks and computes stats to be rendered on the /statusz page.
traceSaver func(spans *protos.TraceSpans) error
pp *logging.PrettyPrinter

mu sync.Mutex
listeners map[string][]string // listener addresses, keyed by name
Expand Down Expand Up @@ -131,6 +132,7 @@ func newSingleprocessEnv(bootstrap runtime.Bootstrap) (*singleprocessEnv, error)
listeners: map[string][]string{},
statsProcessor: imetrics.NewStatsProcessor(),
traceSaver: traceSaver,
pp: logging.NewPrettyPrinter(colors.Enabled()),
}
go func() {
err := env.statsProcessor.CollectMetrics(ctx, metrics.Snapshot)
Expand Down Expand Up @@ -320,9 +322,8 @@ func (e *singleprocessEnv) Profile(_ context.Context, req *protos.GetProfileRequ
}

func (e *singleprocessEnv) CreateLogSaver() func(entry *protos.LogEntry) {
pp := logging.NewPrettyPrinter(colors.Enabled())
return func(entry *protos.LogEntry) {
msg := pp.Format(entry)
msg := e.pp.Format(entry)
if e.bootstrap.Quiet {
// Note that we format the log entry regardless of whether we print
// it so that benchmark results are not skewed significantly by the
Expand Down

0 comments on commit e3bf5a2

Please sign in to comment.