testlog

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2019 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package testlog creates a *log.Logger backed by *testing.T to ease logging in tests. This allows logs from components being tested to only be printed if the test fails (or the verbose flag is specified).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logger

func Logger(t LogPrinter) *log.Logger

NewLog logger with "TEST" prefix and the Lmicroseconds flag.

func New

func New(t LogPrinter, prefix string, flag int) *log.Logger

New returns a new test logger. See https://golang.org/pkg/log/#New

func NewWriter

func NewWriter(t LogPrinter) io.Writer

NewWriter creates a new io.Writer backed by a Logger.

func UseStdout

func UseStdout() bool

UseStdout returns true if NOMAD_TEST_STDOUT=1 and sends logs to stdout.

func WithPrefix

func WithPrefix(t LogPrinter, prefix string) *log.Logger

WithPrefix returns a new test logger with the Lmicroseconds flag set.

Types

type LogPrinter

type LogPrinter interface {
	Logf(format string, args ...interface{})
}

LogPrinter is the methods of testing.T (or testing.B) needed by the test logger.

Jump to

Keyboard shortcuts

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