MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / SetUpGlobalTestLogging

Function SetUpGlobalTestLogging

base/util_testing.go:566–584  ·  view source on GitHub ↗

SetUpGlobalTestLogging sets a global log level at runtime by using the SG_TEST_LOG_LEVEL environment variable. This global level overrides any tests that specify their own test log level with SetUpTestLogging.

(ctx context.Context)

Source from the content-addressed store, hash-verified

564// SetUpGlobalTestLogging sets a global log level at runtime by using the SG_TEST_LOG_LEVEL environment variable.
565// This global level overrides any tests that specify their own test log level with SetUpTestLogging.
566func SetUpGlobalTestLogging(ctx context.Context) (teardownFn func()) {
567 if logLevel := os.Getenv(TestEnvGlobalLogLevel); logLevel != "" {
568 var l LogLevel
569 err := l.UnmarshalText([]byte(logLevel))
570 if err != nil {
571 FatalfCtx(ctx, "TEST: Invalid log level used for %q: %s", TestEnvGlobalLogLevel, err)
572 }
573 caller := GetCallersName(1, false)
574 InfofCtx(context.Background(), KeyAll, "%s: Setup logging: level: %v - keys: %v", caller, logLevel, KeyAll)
575 teardown := setTestLogging(l, caller, KeyAll)
576 GlobalTestLoggingSet.Set(true)
577 return func() {
578 teardown()
579 GlobalTestLoggingSet.Set(false)
580 }
581 }
582 // noop
583 return func() { GlobalTestLoggingSet.Set(false) }
584}
585
586// SetUpTestLogging will set the given log level and log keys, and revert the changes at the end of the current test.
587//

Callers 3

TestMainFunction · 0.92
ResetGlobalTestLoggingFunction · 0.85
TestBucketPoolMainFunction · 0.85

Calls 6

UnmarshalTextMethod · 0.95
FatalfCtxFunction · 0.85
GetCallersNameFunction · 0.85
setTestLoggingFunction · 0.85
InfofCtxFunction · 0.70
SetMethod · 0.45

Tested by 2

TestMainFunction · 0.74
TestBucketPoolMainFunction · 0.68