From 939c0100a68f90643c951dd2137da85c7b5174e2 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Tue, 13 Dec 2022 17:27:40 +0100 Subject: [PATCH] log: Do not interpret verbs in object names in console output (#16233) --- cmd/server-main.go | 2 +- internal/color/color.go | 9 ++++++++- internal/logger/target/console/console.go | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cmd/server-main.go b/cmd/server-main.go index ae9d2ecd2..7022f59be 100644 --- a/cmd/server-main.go +++ b/cmd/server-main.go @@ -541,7 +541,7 @@ func serverMain(ctx *cli.Context) { maxProcs := runtime.GOMAXPROCS(0) cpuProcs := runtime.NumCPU() if maxProcs < cpuProcs { - logger.Info(color.RedBold("WARNING: Detected GOMAXPROCS(%d) < NumCPU(%d), please make sure to provide all PROCS to MinIO for optimal performance", maxProcs, cpuProcs)) + logger.Info(color.RedBoldf("WARNING: Detected GOMAXPROCS(%d) < NumCPU(%d), please make sure to provide all PROCS to MinIO for optimal performance", maxProcs, cpuProcs)) } // Configure server. diff --git a/internal/color/color.go b/internal/color/color.go index 742bef906..3cd3c1188 100644 --- a/internal/color/color.go +++ b/internal/color/color.go @@ -38,7 +38,14 @@ var ( return fmt.Sprintf }() - RedBold = func() func(format string, a ...interface{}) string { + RedBold = func() func(a ...interface{}) string { + if IsTerminal() { + return color.New(color.FgRed, color.Bold).SprintFunc() + } + return fmt.Sprint + }() + + RedBoldf = func() func(format string, a ...interface{}) string { if IsTerminal() { return color.New(color.FgRed, color.Bold).SprintfFunc() } diff --git a/internal/logger/target/console/console.go b/internal/logger/target/console/console.go index acf74aff9..e91ddfaf0 100644 --- a/internal/logger/target/console/console.go +++ b/internal/logger/target/console/console.go @@ -133,7 +133,7 @@ func (c *Target) Send(e interface{}, logKind string) error { tagString = "\n " + tagString } - msg := color.FgRed(color.Bold(entry.Trace.Message)) + msg := color.RedBold(entry.Trace.Message) output := fmt.Sprintf("\n%s\n%s%s%s%s%s%s\nError: %s%s\n%s", apiString, timeString, deploymentID, requestID, remoteHost, host, userAgent, msg, tagString, strings.Join(trace, "\n"))