Documentation ¶
Overview ¶
Package testlogging implements logger that writes to testing.T log.
Index ¶
- Constants
- func Context(t testingT) context.Context
- func ContextWithLevel(t testingT, level Level) context.Context
- func ContextWithLevelAndPrefix(t testingT, level Level, prefix string) context.Context
- func ContextWithLevelAndPrefixFunc(t testingT, level Level, prefixFunc func() string) context.Context
- func NewTestLogger(t *testing.T) logging.Logger
- func Printf(printf func(msg string, args ...interface{}), prefix string) *zap.SugaredLogger
- func PrintfFactory(printf func(msg string, args ...interface{})) logging.LoggerFactory
- func PrintfLevel(printf func(msg string, args ...interface{}), prefix string, ...) *zap.SugaredLogger
- type Level
Constants ¶
const ( LevelDebug = zapcore.DebugLevel LevelInfo = zapcore.InfoLevel LevelWarn = zapcore.WarnLevel LevelError = zapcore.ErrorLevel )
log levels.
Variables ¶
This section is empty.
Functions ¶
func Context ¶
Context returns a context with attached logger that emits all log entries to go testing.T log output.
func ContextWithLevel ¶
ContextWithLevel returns a context with attached logger that emits all log entries with given log level or above.
func ContextWithLevelAndPrefix ¶ added in v0.6.0
ContextWithLevelAndPrefix returns a context with attached logger that emits all log entries with given log level or above.
func ContextWithLevelAndPrefixFunc ¶ added in v0.6.0
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 ¶ added in v0.9.0
NewTestLogger returns logger bound to the provided testing.T.
func Printf ¶ added in v0.11.0
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 ¶ added in v0.11.0
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 ¶ added in v0.11.0
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.