Skip to content

Commit ad19592

Browse files
authored
fix(spanner): disable config logging by default (#13478)
Disables the config logging at startup by default. Config logging can be enabled by setting either of the environment variables `GOOGLE_CLOUD_SPANNER_ENABLE_LOG_CLIENT_OPTIONS` or `GOOGLE_CLOUD_SPANNER_DISABLE_LOG_CLIENT_OPTIONS`. If neither of these variables have been set, logging will be disabled.
1 parent 3851406 commit ad19592

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

spanner/client.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,12 +1527,20 @@ func parseServerTimingHeader(md metadata.MD) map[string]time.Duration {
15271527
return metrics
15281528
}
15291529

1530-
// enableLogClientOptions returns true if the environment variable for this doesn't exist or is set to false
1530+
// enableLogClientOptions returns true if the environment variable for enabling has been set to true, or if the
1531+
// environment variable for disabling has been set to false. It returns false by default if no env var has been set.
1532+
// The function uses two environment variables because this function was initially added with a default return value of
1533+
// true, which caused the config to always be logged. This again caused unnecessary log spamming.
15311534
func enableLogClientOptions() bool {
1535+
if enableLogString, found := os.LookupEnv("GOOGLE_CLOUD_SPANNER_ENABLE_LOG_CLIENT_OPTIONS"); found {
1536+
if enableLog, err := strconv.ParseBool(enableLogString); err == nil {
1537+
return enableLog
1538+
}
1539+
}
15321540
if disableLogString, found := os.LookupEnv("GOOGLE_CLOUD_SPANNER_DISABLE_LOG_CLIENT_OPTIONS"); found {
15331541
if disableLog, err := strconv.ParseBool(disableLogString); err == nil {
15341542
return !disableLog
15351543
}
15361544
}
1537-
return true
1545+
return false
15381546
}

0 commit comments

Comments
 (0)