logwatch

package
v1.19.5 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContainerLogConsumer

type ContainerLogConsumer struct {
	Messages []string
	// contains filtered or unexported fields
}

ContainerLogConsumer is a container log lines consumer

func (*ContainerLogConsumer) Accept

func (g *ContainerLogConsumer) Accept(l testcontainers.Log)

Accept accepts the log message from particular container

func (*ContainerLogConsumer) FindMatch

func (g *ContainerLogConsumer) FindMatch(l testcontainers.Log) int

FindMatch check multiple regex patterns for the same string can be checked with one regex, made for readability of user-facing API

type LogNotification

type LogNotification struct {
	Container string
	Prefix    string
	Log       string
}

LogNotification notification about log line match for some container

type LogWatch

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

LogWatch is a test helper struct to monitor docker container logs for some patterns and push their logs into Loki for further analysis

func NewLogWatch

func NewLogWatch(t *testing.T, patterns map[string][]*regexp.Regexp) (*LogWatch, error)

NewLogWatch creates a new LogWatch instance, with a Loki client

func (*LogWatch) AllLogs

func (m *LogWatch) AllLogs() []string

AllLogs returns all logs for all containers

func (*LogWatch) ConnectContainer

func (m *LogWatch) ConnectContainer(ctx context.Context, container testcontainers.Container, prefix string, pushToLoki bool) error

ConnectContainer connects consumer to selected container and starts testcontainers.LogProducer

func (*LogWatch) ContainerLogs

func (m *LogWatch) ContainerLogs(name string) []string

ContainerLogs return all logs for the particular container

func (*LogWatch) DisconnectContainer

func (m *LogWatch) DisconnectContainer(container testcontainers.Container)

DisconnectContainer disconnects the particular container

func (*LogWatch) Listen

func (m *LogWatch) Listen() *LogNotification

Listen listen for the next notification

func (*LogWatch) OnMatch

func (m *LogWatch) OnMatch(f func(ln *LogNotification))

OnMatch calling your testing hook on first match

func (*LogWatch) PrintAll

func (m *LogWatch) PrintAll()

PrintAll prints all logs for all containers connected

func (*LogWatch) Shutdown

func (m *LogWatch) Shutdown()

Shutdown disconnects all containers, stops notifications

Jump to

Keyboard shortcuts

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