From b8771844875d2717e2e51d454a7a1f7a2faf1aab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Wei=C3=9Fe?= Date: Fri, 27 Jan 2023 15:04:55 +0100 Subject: [PATCH] Disable stack trace on error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Weiße --- cmd/coordinator/run.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cmd/coordinator/run.go b/cmd/coordinator/run.go index c58751b3..dd169d5c 100644 --- a/cmd/coordinator/run.go +++ b/cmd/coordinator/run.go @@ -7,6 +7,7 @@ package main import ( + "fmt" "os" "strings" @@ -35,16 +36,17 @@ func run(validator quote.Validator, issuer quote.Issuer, sealDir string, sealer devMode := util.Getenv(constants.DevMode, constants.DevModeDefault) == "1" // Setup logging with Zap Logger - // Development Logger shows a stacktrace for warnings & errors, Production Logger only for errors - var log *zap.Logger - var err error + var cfg zap.Config if devMode { - log, err = zap.NewDevelopment() + cfg = zap.NewDevelopmentConfig() } else { - log, err = zap.NewProduction() + cfg = zap.NewProductionConfig() + cfg.DisableStacktrace = true // Disable stacktraces in production } + log, err := cfg.Build() if err != nil { - panic(err) + fmt.Fprintf(os.Stderr, "failed to create logger: %s\n", err) + os.Exit(1) } defer log.Sync() // flushes buffer, if any