package testr
import "github.com/go-logr/logr/testr"
Package testr provides support for using logr in tests.
Index ¶
- func New(t *testing.T) logr.Logger
- func NewWithInterface(t TestingT, opts Options) logr.Logger
- func NewWithOptions(t *testing.T, opts Options) logr.Logger
- type Options
- type TestingT
- type Underlier
- type UnderlierInterface
Functions ¶
func New ¶
New returns a logr.Logger that prints through a testing.T object. Info logs are only enabled at V(0).
func NewWithInterface ¶
NewWithInterface returns a logr.Logger that prints through a TestingT object. In contrast to the simpler New, output formatting can be configured.
func NewWithOptions ¶
NewWithOptions returns a logr.Logger that prints through a testing.T object. In contrast to the simpler New, output formatting can be configured.
Types ¶
type Options ¶
type Options struct { // LogTimestamp tells the logger to add a "ts" key to log // lines. This has some overhead, so some users might not want // it. LogTimestamp bool // Verbosity tells the logger which V logs to be write. // Higher values enable more logs. Verbosity int }
Options carries parameters which influence the way logs are generated.
type TestingT ¶
type TestingT interface { Helper() Log(args ...any) }
TestingT is an interface wrapper around testing.T, testing.B and testing.F.
type Underlier ¶
Underlier exposes access to the underlying testing.T instance. Since callers only have a logr.Logger, they have to know which implementation is in use, so this interface is less of an abstraction and more of a way to test type conversion.
type UnderlierInterface ¶
type UnderlierInterface interface { GetUnderlying() TestingT }
UnderlierInterface exposes access to the underlying TestingT instance. Since callers only have a logr.Logger, they have to know which implementation is in use, so this interface is less of an abstraction and more of a way to test type conversion.
Source Files ¶
- Version
- v1.4.2 (latest)
- Published
- May 20, 2024
- Platform
- linux/amd64
- Imports
- 3 packages
- Last checked
- 5 days ago –
Tools for package owners.