mirror of
https://github.com/restic/restic.git
synced 2024-12-21 23:33:03 +00:00
d1a5ec7839
The parameter is an additional marker that the test helper must only be used for tests.
23 lines
449 B
Go
23 lines
449 B
Go
package debug
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
// TestLogToStderr configures debug to log to stderr if not the debug log is
|
|
// not already configured and returns whether logging was enabled.
|
|
func TestLogToStderr(_ testing.TB) bool {
|
|
if opts.isEnabled {
|
|
return false
|
|
}
|
|
opts.logger = log.New(os.Stderr, "", log.LstdFlags)
|
|
opts.isEnabled = true
|
|
return true
|
|
}
|
|
|
|
func TestDisableLog(_ testing.TB) {
|
|
opts.logger = nil
|
|
opts.isEnabled = false
|
|
}
|