loggingtest

package
v0.0.0-...-b5d9cbe Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package loggingtest provides logging utilities for unit tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger is a logging.Logger that accumulates logs to an in-memory buffer, as well as emitting them as unit test logs.

This is useful for unit tests that inspect logs from a function call.

func NewLogger

func NewLogger(t *testing.T, level logging.Level) *Logger

NewLogger creates a new Logger.

func (*Logger) Log

func (l *Logger) Log(level logging.Level, ts time.Time, msg string)

Log gets called for a log event.

func (*Logger) Logs

func (l *Logger) Logs() []string

Logs returns a list of logs received so far.

func (*Logger) String

func (l *Logger) String() string

String returns received logs as a newline-separated string.

Jump to

Keyboard shortcuts

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