Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(spanner): configurable logger #6958

Merged
merged 4 commits into from Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions spanner/client.go
Expand Up @@ -143,9 +143,9 @@ type ClientConfig struct {
// Recommended format: ``application-or-tool-ID/major.minor.version``.
UserAgent string

// logger is the logger to use for this client. If it is nil, all logging
// Logger is the logger to use for this client. If it is nil, all logging
// will be directed to the standard logger.
logger *log.Logger
Logger *log.Logger
}

func contextWithOutgoingMetadata(ctx context.Context, md metadata.MD) context.Context {
Expand Down Expand Up @@ -220,7 +220,7 @@ func NewClientWithConfig(ctx context.Context, database string, config ClientConf
config.incStep = DefaultSessionPoolConfig.incStep
}
// Create a session client.
sc := newSessionClient(pool, database, config.UserAgent, sessionLabels, metadata.Pairs(resourcePrefixHeader, database), config.logger, config.CallOptions)
sc := newSessionClient(pool, database, config.UserAgent, sessionLabels, metadata.Pairs(resourcePrefixHeader, database), config.Logger, config.CallOptions)
// Create a session pool.
config.SessionPoolConfig.sessionLabels = sessionLabels
sp, err := newSessionPool(sc, config.SessionPoolConfig)
Expand All @@ -231,7 +231,7 @@ func NewClientWithConfig(ctx context.Context, database string, config ClientConf
c = &Client{
sc: sc,
idleSessions: sp,
logger: config.logger,
logger: config.Logger,
qo: getQueryOptions(config.QueryOptions),
ro: config.ReadOptions,
ao: config.ApplyOptions,
Expand Down
2 changes: 1 addition & 1 deletion spanner/pdml_test.go
Expand Up @@ -114,7 +114,7 @@ func TestPartitionedUpdate_WithDeadline(t *testing.T) {
logger := log.New(os.Stderr, "", log.LstdFlags)
server, client, teardown := setupMockedTestServerWithConfig(t, ClientConfig{
SessionPoolConfig: DefaultSessionPoolConfig,
logger: logger,
Logger: logger,
})
defer teardown()

Expand Down
4 changes: 2 additions & 2 deletions spanner/session_test.go
Expand Up @@ -1122,7 +1122,7 @@ func TestErrorOnPrepareSession(t *testing.T) {
WriteSessions: 0.5,
HealthCheckInterval: time.Millisecond,
},
logger: logger,
Logger: logger,
})
defer teardown()
// Discard logging until trying to prepare sessions has stopped.
Expand Down Expand Up @@ -1244,7 +1244,7 @@ func TestSessionNotFoundOnPrepareSession(t *testing.T) {
HealthCheckInterval: time.Millisecond,
healthCheckSampleInterval: time.Millisecond,
},
logger: logger,
Logger: logger,
})
defer teardown()
// Discard logging until trying to prepare sessions has stopped.
Expand Down