logger

package
v1.5.0-dev14 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Overview

DataFrame wraps the byte framing used by docker to multiplex output from a docker container when there is no TTY in use. Although docker provides some functions to work with this stream, we want to keep our data in this form as long as possible, as well as making it implementable by other executors.

Docker documents this as:

[8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}[]byte{OUTPUT}

STREAM_TYPE can be 1 for stdout and 2 for stderr

SIZE1, SIZE2, SIZE3, and SIZE4 are four bytes of uint32 encoded as big endian. This is the size of OUTPUT.

Index

Constants

View Source
const HeaderLength = 8

Variables

This section is empty.

Functions

func ConfigureLogging

func ConfigureLogging(modeStr, levelStr string) error

func ConfigureTestLogging

func ConfigureTestLogging(t tTesting)

ConfigureTestLogging allows logs to be associated with individual tests

func ContextWithNodeIDLogger

func ContextWithNodeIDLogger(ctx context.Context, nodeID string) context.Context

ContextWithNodeIDLogger will return a context with nodeID is added to the logging context.

func ErrOrDebug added in v0.3.29

func ErrOrDebug(err error) zerolog.Level

func LogBufferedLogs

func LogBufferedLogs(writer io.Writer)

LogBufferedLogs will log any log messages written from before logging was configured to the given writer. If writer is nil, then the default logging will be used instead. This function will do nothing once the buffer has been outputted.

func LogStream

func LogStream(ctx context.Context, r io.Reader)

func ToSliceStringer added in v0.3.24

func ToSliceStringer[T any](ts []T, f func(t T) string) []fmt.Stringer

func ToStringer added in v0.3.24

func ToStringer[T any](t T, f func(t T) string) fmt.Stringer

Types

type DataFrame added in v0.3.29

type DataFrame struct {
	Tag  StreamTag
	Size int
	Data []byte
}

func NewDataFrameFromData added in v0.3.29

func NewDataFrameFromData(tag StreamTag, data []byte) *DataFrame

NewDataFrameFromBytes will compose a new data frame wrapping the provided tag and data with the necessary structure.

func NewDataFrameFromReader added in v0.3.29

func NewDataFrameFromReader(reader io.Reader) (*DataFrame, error)

func (DataFrame) ToBytes added in v0.3.29

func (df DataFrame) ToBytes() []byte

ToBytes converts the data frame into a format suitable for transmission across a Writer.

type LogMode

type LogMode string
const (
	LogModeDefault  LogMode = "default"
	LogModeStation  LogMode = "station"
	LogModeJSON     LogMode = "json"
	LogModeCombined LogMode = "combined"
	LogModeEvent    LogMode = "event"
)

Available logging modes

func ParseLogMode

func ParseLogMode(s string) (LogMode, error)

type StreamTag added in v0.3.29

type StreamTag byte
const (
	UnknownStreamTag StreamTag = iota
	StdoutStreamTag
	StderrStreamTag
)

Directories

Path Synopsis
testpackage

Jump to

Keyboard shortcuts

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