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
This commit is contained in:
Ilia Babanov 2023-11-08 09:51:01 +01:00 committed by GitHub
parent 7509e4d55a
commit 65dd9c5c0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"io" "io"
"log/slog" "log/slog"
"os"
"github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/env"
@ -113,7 +114,7 @@ func (f *logFlags) initializeContext(ctx context.Context) (context.Context, erro
return nil, err 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 return log.NewContext(ctx, slog.Default()), nil
} }