logging

package
v0.0.0-...-ec710b4 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogLevelEnvVar = "TEST_LOG_LEVEL"
)

Variables

Functions

func GetLogger

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

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

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

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

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

Types

type CustomT

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

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

Printf implements the testcontainers-go/Logging interface.

func (*CustomT) Write

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