Skip to content

Commit 65dd9c5

Browse files
authored
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: databricks/databricks-vscode#923 ## Tests Tested manually for sdk and cli loggers
1 parent 7509e4d commit 65dd9c5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

cmd/root/logger.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"io"
77
"log/slog"
8+
"os"
89

910
"github.com/databricks/cli/libs/cmdio"
1011
"github.com/databricks/cli/libs/env"
@@ -113,7 +114,7 @@ func (f *logFlags) initializeContext(ctx context.Context) (context.Context, erro
113114
return nil, err
114115
}
115116

116-
slog.SetDefault(slog.New(handler))
117+
slog.SetDefault(slog.New(handler).With(slog.Int("pid", os.Getpid())))
117118
return log.NewContext(ctx, slog.Default()), nil
118119
}
119120

0 commit comments

Comments
 (0)