// RedirectKlog modifies the global klog logger so that it writes via the given // writer. This only works when different tests run sequentially. // // The returned cleanup function restores the previous state. Beware that it is // not thread-safe, all goroutines which call klog must have been stopped. func RedirectKlog(tb testing.TB, output io.Writer) func() { … } // NewTBWriter creates an io.Writer which turns each write into a tb.Log call. // // Note that no attempts are made to determine the actual call site because // our caller doesn't know about the TB instance and thus cannot mark itself // as helper. Therefore the code here doesn't do it either and thus shows up // as call site in the testing output. To avoid that, contextual logging // and ktesting have to be used. func NewTBWriter(tb testing.TB) io.Writer { … } type testingWriter … func (tw testingWriter) Write(data []byte) (int, error) { … } var _ …