Skip to content

Commit

Permalink
Log process ID in each log entry (#949)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
ilia-db authored Nov 8, 2023
1 parent 7509e4d commit 65dd9c5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/root/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"io"
"log/slog"
"os"

"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/env"
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 65dd9c5

Please sign in to comment.