testlogtransport

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TransportTest

type TransportTest struct {
	Events      []testLogRecord
	LogMessages map[uclog.LogLevel][]string
	// contains filtered or unexported fields
}

TransportTest is a test log transport

func InitLoggerAndTransportsForTests

func InitLoggerAndTransportsForTests(t *testing.T) *TransportTest

InitLoggerAndTransportsForTests configures logging to use golang test logging TODO: once we simplify log config & init, this can get unified through the main Init() path, but I don't want to introduce yet another config fork for this TODO: is there a way to do this more automatically than per-test? TestMain doesn't have testing.T or .B TODO: the fact that this returns a *bytes.Buffer representing the log is pretty icky

func InitLoggerAndTransportsForTestsWithLevel added in v0.8.5

func InitLoggerAndTransportsForTestsWithLevel(t *testing.T, logLevel uclog.LogLevel) *TransportTest

InitLoggerAndTransportsForTestsWithLevel configures logging to use golang test logging with a specific log level

func (*TransportTest) AssertLogsContainString added in v1.1.0

func (tt *TransportTest) AssertLogsContainString(strs ...string)

AssertLogsContainString asserts that at least one log message contains a one of the strings passed to this function

func (*TransportTest) AssertLogsDoesntContainString added in v1.1.0

func (tt *TransportTest) AssertLogsDoesntContainString(s string)

AssertLogsDoesntContainString asserts that no log message contains a particular string

func (*TransportTest) AssertMessagesByLogLevel added in v0.8.3

func (tt *TransportTest) AssertMessagesByLogLevel(level uclog.LogLevel, expected int, opts ...assert.Option)

AssertMessagesByLogLevel asserts that the number of messages logged at a particular level is as expected

func (*TransportTest) ClearEvents

func (tt *TransportTest) ClearEvents()

ClearEvents clears all logged events

func (*TransportTest) ClearMessages added in v0.8.5

func (tt *TransportTest) ClearMessages()

ClearMessages clears all logged messages

func (*TransportTest) Close

func (tt *TransportTest) Close()

Close prevents writing to the transport after a test ends see https://github.com/golang/go/issues/40343

func (*TransportTest) Flush

func (tt *TransportTest) Flush() error

Flush does nothing

func (*TransportTest) GetEventsLoggedByName

func (tt *TransportTest) GetEventsLoggedByName(name string) []uclog.LogEvent

GetEventsLoggedByName checks if a particular event has been logged

func (*TransportTest) GetName

func (tt *TransportTest) GetName() string

GetName returns transport name

func (*TransportTest) GetStats

func (tt *TransportTest) GetStats() uclog.LogTransportStats

GetStats returns stats

func (*TransportTest) Init

func (tt *TransportTest) Init() (*uclog.TransportConfig, error)

Init initializes the test transport

func (*TransportTest) Write added in v0.8.0

func (tt *TransportTest) Write(ctx context.Context, event uclog.LogEvent)

Write writes an event

Jump to

Keyboard shortcuts

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