From e3bf5a2000871f51654c10a714b038090e0a1462 Mon Sep 17 00:00:00 2001 From: Michael Whittaker Date: Tue, 23 May 2023 14:18:12 -0700 Subject: [PATCH] Fixed single process pretty printer bug. 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. --- singleprocess.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/singleprocess.go b/singleprocess.go index 025a5d21f..cb052930c 100644 --- a/singleprocess.go +++ b/singleprocess.go @@ -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 @@ -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) @@ -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