From 65dd9c5c0f8fa04f1ad9f7676718eb44b74da3d3 Mon Sep 17 00:00:00 2001 From: Ilia Babanov Date: Wed, 8 Nov 2023 09:51:01 +0100 Subject: [PATCH] Log process ID in each log entry (#949) ## Changes This will help differentiate multiple cli commands that write to the same log file. Noticed that the root module wasn't using the common log utilities, refactored it to avoid missing log arguments. Relevant PR on the databricks vscode extension side: https://github.com/databricks/databricks-vscode/pull/923 ## Tests Tested manually for sdk and cli loggers --- cmd/root/logger.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/root/logger.go b/cmd/root/logger.go index dca07ca4be..0ad6756afb 100644 --- a/cmd/root/logger.go +++ b/cmd/root/logger.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "log/slog" + "os" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/env" @@ -113,7 +114,7 @@ func (f *logFlags) initializeContext(ctx context.Context) (context.Context, erro return nil, err } - slog.SetDefault(slog.New(handler)) + slog.SetDefault(slog.New(handler).With(slog.Int("pid", os.Getpid()))) return log.NewContext(ctx, slog.Default()), nil }