...

Source file src/github.com/wojas/genericr/testlogger.go

Documentation: github.com/wojas/genericr

     1  package genericr
     2  
     3  import (
     4  	"github.com/go-logr/logr"
     5  )
     6  
     7  // TLogSink is the subset of the testing.TB interface we need to log with it
     8  type TLogSink interface {
     9  	Log(args ...interface{})
    10  }
    11  
    12  // NewForTesting returns a LogSink for given testing.T or B.
    13  // Note that the source line reference will be incorrect in all messages
    14  // written by testing.T. There is nothing we can do about that, the call depth
    15  // is hardcoded in there.
    16  func NewForTesting(t TLogSink) logr.Logger {
    17  	var f LogFunc = func(e Entry) {
    18  		t.Log(e.String())
    19  	}
    20  	sink := New(f)
    21  	return logr.New(sink)
    22  }
    23  

View as plain text