testr

package module
v0.0.0-...-d38912d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

README

Minimal Go logging using logr and Go's standard library

This package implements the logr interface in terms of Go's test package log methods.

Pro's and con's

  • Log output is only shown for failing tests.
  • Filename/line number printed in the log message is always the same (GO test package Log() can't skip stacklevels).

Documentation

Overview

Package testr implements github.com/go-logr/logr.Logger in terms of Go's test package log method.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(std TestLogger) logr.Logger

New returns a logr.Logger which is implemented by Go's test package Log().

Example: testr.New(t)

func SetVerbosity

func SetVerbosity(v int) int

SetVerbosity sets the global level against which all info logs will be compared. If this is greater than or equal to the "V" of the logger, the message will be logged. A higher value here means more logs will be written. The previous verbosity value is returned. This is not concurrent-safe - callers must be sure to call it from only one goroutine.

Types

type TestLogger

type TestLogger interface {
	// Log matches https://pkg.go.dev/testing?tab=doc#B.Log
	Log(args ...interface{})
}

TestLogger is the subset of the Go test package Log API that is needed for this adapter.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL