testlogging

package
v0.0.0-...-58c64f7 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package testlogging implements logger that writes to testing.T log.

Index

Constants

View Source
const (
	LevelDebug = zapcore.DebugLevel
	LevelInfo  = zapcore.InfoLevel
	LevelWarn  = zapcore.WarnLevel
	LevelError = zapcore.ErrorLevel
)

log levels.

Variables

This section is empty.

Functions

func Context

func Context(t testingT) context.Context

Context returns a context with attached logger that emits all log entries to go testing.T log output.

func ContextWithLevel

func ContextWithLevel(t testingT, level Level) context.Context

ContextWithLevel returns a context with attached logger that emits all log entries with given log level or above.

func ContextWithLevelAndPrefix

func ContextWithLevelAndPrefix(t testingT, level Level, prefix string) context.Context

ContextWithLevelAndPrefix returns a context with attached logger that emits all log entries with given log level or above.

func ContextWithLevelAndPrefixFunc

func ContextWithLevelAndPrefixFunc(t testingT, level Level, prefixFunc func() string) context.Context

ContextWithLevelAndPrefixFunc returns a context with attached logger that emits all log entries with given log level or above.

func NewTestLogger

func NewTestLogger(t *testing.T) logging.Logger

NewTestLogger returns logger bound to the provided testing.T.

func Printf

func Printf(printf func(msg string, args ...interface{}), prefix string) *zap.SugaredLogger

Printf returns a logger that uses given printf-style function to print log output.

func PrintfFactory

func PrintfFactory(printf func(msg string, args ...interface{})) logging.LoggerFactory

PrintfFactory returns LoggerForModuleFunc that uses given printf-style function to print log output.

func PrintfLevel

func PrintfLevel(printf func(msg string, args ...interface{}), prefix string, level zapcore.Level) *zap.SugaredLogger

PrintfLevel returns a logger that uses given printf-style function to print log output for logs of a given level or above.

Types

type Level

type Level = zapcore.Level

Level specifies log level.

Jump to

Keyboard shortcuts

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