test

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoSomeLogging

func DoSomeLogging(cfg DoSomeLoggingCfg) (logged int32, filtered int32)

DoSomeLogging performs some concurrent logging on a preconfigured Logr.

func StringRnd

func StringRnd(length int) string

StringRnd returns a pseudo-random string of the specified length.

Types

type Buffer

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

Buffer is a simple buffer implementing io.Writer

func (*Buffer) Bytes

func (b *Buffer) Bytes() []byte

Bytes returns buffer contents as a slice.

func (*Buffer) String

func (b *Buffer) String() string

String returns the buffer as a string.

func (*Buffer) Write

func (b *Buffer) Write(data []byte) (int, error)

Write adds data to the buffer.

type DoSomeLoggingCfg

type DoSomeLoggingCfg struct {
	// Lgr is a preconfigured Logr instance.
	Lgr *logr.Logr
	// Goroutines is number of goroutines to start.
	Goroutines int
	// Loops is number of loops per goroutine.
	Loops int
	// GoodToken is some text that is output for log statements that
	// should be output.
	GoodToken string
	// BadToken is text that is output for log statements that should be
	// filtered out.
	BadToken string
	// Lvl is the Level to use for log statements.
	Lvl logr.Level
	// Delay is amount of time to pause between loops.
	Delay time.Duration
}

DoSomeLoggingCfg is configuration for `DoSomeLogging` utility.

type SlowTarget

type SlowTarget struct {
	logr.Basic

	Delay time.Duration
	// contains filtered or unexported fields
}

SlowTarget outputs log records to any `io.Writer` with configurable delay to simulate slower targets. Modify SlowTarget.Delay to determine the pause per log record.

func NewSlowTarget

func NewSlowTarget(filter logr.Filter, formatter logr.Formatter, out io.Writer, maxQueue int) *SlowTarget

NewSlowTarget creates a new SlowTarget.

func (*SlowTarget) String

func (st *SlowTarget) String() string

String returns a string representation of this target.

func (*SlowTarget) Write

func (st *SlowTarget) Write(rec *logr.LogRec) error

Write converts the log record to bytes, via the Formatter, and outputs to the io.Writer.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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