processlog

package
v0.0.39 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2023 License: MIT Imports: 12 Imported by: 1

Documentation

Overview

Package processlog contains an opinionated method for piping logs from external processes into stdout and readbale files for testing.. This is useful for debugging external processes

Index

Constants

View Source
const (
	// StdOutSuffix is the standard out file suffix.
	StdOutSuffix = "stdout.log"
	// StdErrSuffix is the standard err suffix.
	StdErrSuffix = "stderr.log"
	// CombinedSuffix is the combined file suffix.
	CombinedSuffix = "combined.log"
)

Variables

This section is empty.

Functions

func CombineStreams

func CombineStreams(ctx context.Context, inputs ...io.ReadCloser) (output chan []byte, errChan chan error)

CombineStreams creates a combined stream of two io.readClosers this is commonly used for combining stdout and stderr. nolint: cyclop

func SplitStreams

func SplitStreams(input io.Reader, splitCount int) (outputReaders []io.ReadCloser)

SplitStreams splits an input into multiple io.readers TODO this should return an object with an iterator to prevent reuse.

Types

type LogMetadata

type LogMetadata interface {
	// LogDir gets the log directory.
	LogDir() string
	// StdOutFile gets the log directory.
	StdOutFile() string
	// StdErrFile gets the log directory.
	StdErrFile() string
	// CombinedFile gets the log directory.
	CombinedFile() string
}

LogMetadata provides an interface for getting locations of process log files.

func StartLogs

func StartLogs(opts ...StdStreamLogArgsOption) (_ LogMetadata, err error)

StartLogs starts the log process.

type PrintFunc

type PrintFunc func([]byte)

PrintFunc is the function used to print data to the desired logger.

type StdStreamLogArgsOption

type StdStreamLogArgsOption func(*stdStreamLogArgs)

StdStreamLogArgsOption is a function that modifies a stdStreamLogArgs struct field.

func WithAccumulator

func WithAccumulator(accumulator *bytes.Buffer) StdStreamLogArgsOption

WithAccumulator returns a function that modifies the Accumulator field of a stdStreamLogArgs struct.

func WithCtx

WithCtx returns a function that modifies the Ctx field of a stdStreamLogArgs struct.

func WithLogDir

func WithLogDir(logDir string) StdStreamLogArgsOption

WithLogDir returns a function that modifies the LogDir field of a stdStreamLogArgs struct.

func WithLogFileName

func WithLogFileName(logFileName string) StdStreamLogArgsOption

WithLogFileName returns a function that modifies the LogFileName field of a stdStreamLogArgs struct.

func WithLogFrequency

func WithLogFrequency(logFrequency time.Duration) StdStreamLogArgsOption

WithLogFrequency returns a function that modifies the LogFrequency field of a stdStreamLogArgs struct.

func WithPrintFunc

func WithPrintFunc(printFunc PrintFunc) StdStreamLogArgsOption

WithPrintFunc returns a function that modifies the PrintFunc field of a stdStreamLogArgs struct.

func WithStdErr

func WithStdErr(stdErr io.ReadCloser) StdStreamLogArgsOption

WithStdErr returns a function that modifies the StdErr field of a stdStreamLogArgs struct.

func WithStdOut

func WithStdOut(stdOut io.ReadCloser) StdStreamLogArgsOption

WithStdOut returns a function that modifies the StdOut field of a stdStreamLogArgs struct.

Jump to

Keyboard shortcuts

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