testlogtransport

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2023 License: MIT Imports: 6 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 (*TransportTest) ClearEvents

func (tt *TransportTest) ClearEvents()

ClearEvents clears all logged events

func (*TransportTest) Close

func (tt *TransportTest) Close()

Close does nothing

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) GetLogMessagesByLevel

func (tt *TransportTest) GetLogMessagesByLevel(level uclog.LogLevel) []string

GetLogMessagesByLevel returns log messages by level

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) LogsContainString

func (tt *TransportTest) LogsContainString(s string) bool

LogsContainString returns whether any of the logged messages contain the given string

func (*TransportTest) WriteCounter

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

WriteCounter writes an event

func (*TransportTest) WriteMessage

func (tt *TransportTest) WriteMessage(ctx context.Context, message string, level uclog.LogLevel)

WriteMessage write a message

Jump to

Keyboard shortcuts

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