logging

package
v1.27.7 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 10 Imported by: 8

Documentation

Index

Constants

View Source
const (
	LogLevelEnvVar = "TEST_LOG_LEVEL"
)

Variables

Functions

func GetLogger added in v1.17.0

func GetLogger(t *testing.T, envVarName string) zerolog.Logger

GetLogger returns a logger that will write to the testing.T.Log function using the env var provided for the log level. nil can be passed for t to get a logger that is not associated with a go test.

func GetTestContainersGoTestLogger added in v1.19.0

func GetTestContainersGoTestLogger(t *testing.T) tc.Logging

GetTestContainersGoTestLogger returns a logger that will write to the testing.T.Log function using the env var for log level for logs that testcontainers-go will log out. nil can be passed to this and it will be treated as the default tc.Logger

func GetTestLogger added in v1.17.0

func GetTestLogger(t *testing.T) zerolog.Logger

GetTestLogger returns a logger that will write to the testing.T.Log function using the env var for log level. nil can be passed for t to get a logger that is not associated with a go test.

func Init

func Init()

func SplitStringIntoChunks added in v1.22.1

func SplitStringIntoChunks(s string, chunkSize int) []string

SplitStringIntoChunks takes a string and splits it into chunks of a specified size.

Types

type CustomT added in v1.17.0

type CustomT struct {
	*testing.T
	L zerolog.Logger
	// contains filtered or unexported fields
}

CustomT wraps testing.T for two puposes: 1. it implements Write to override the default logger 2. it implements Printf to implement the testcontainers-go/Logging interface The reason for both of these is that go parallel testing causes the logs to get mixed up, so we need to override the default logger to *testing.T.Log to ensure that the logs are properly associated with the tests running. The testcontainers-go/Logging interface complicates this more since it needs a struct with L to hold the logger and needs to override Printf.

func (CustomT) Printf added in v1.17.0

func (ct CustomT) Printf(format string, v ...interface{})

Printf implements the testcontainers-go/Logging interface.

func (*CustomT) Write added in v1.17.0

func (ct *CustomT) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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