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

Function SetUpBenchmarkLogging

base/util_testing.go:619–634  ·  view source on GitHub ↗

SetUpBenchmarkLogging will set the given log level and key, and do log processing for that configuration, but discards the output, instead of writing it to console.

(tb testing.TB, logLevel LogLevel, logKeys ...LogKey)

Source from the content-addressed store, hash-verified

617// SetUpBenchmarkLogging will set the given log level and key, and do log processing for that configuration,
618// but discards the output, instead of writing it to console.
619func SetUpBenchmarkLogging(tb testing.TB, logLevel LogLevel, logKeys ...LogKey) {
620 teardownFnOrig := setTestLogging(logLevel, "", logKeys...)
621
622 // discard all logging output for benchmarking (but still execute logging as normal)
623 consoleLogger.Load().logger.SetOutput(io.Discard)
624 tb.Cleanup(func() {
625 logger := consoleLogger.Load()
626 // revert back to original output
627 if logger != nil && logger.output != nil {
628 logger.logger.SetOutput(logger.output)
629 } else {
630 logger.logger.SetOutput(os.Stderr)
631 }
632 teardownFnOrig()
633 })
634}
635
636func setTestLogging(logLevel LogLevel, caller string, logKeys ...LogKey) (teardownFn func()) {
637 if GlobalTestLoggingSet.IsTrue() {

Calls 2

setTestLoggingFunction · 0.85
LoadMethod · 0.80