2023-05-01 16:03:17 +00:00
|
|
|
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.
|
2023-05-18 17:23:32 +00:00
|
|
|
func TestLogToStderr(_ testing.TB) bool {
|
2023-05-01 16:03:17 +00:00
|
|
|
if opts.isEnabled {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
opts.logger = log.New(os.Stderr, "", log.LstdFlags)
|
|
|
|
opts.isEnabled = true
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2023-05-18 17:23:32 +00:00
|
|
|
func TestDisableLog(_ testing.TB) {
|
2023-05-01 16:03:17 +00:00
|
|
|
opts.logger = nil
|
|
|
|
opts.isEnabled = false
|
|
|
|
}
|