logbuffer

package
v0.0.0-...-ba854f2 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: Apache-2.0 Imports: 4 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = fmt.Errorf("closed")

ErrClosed is used to indicate the ringbuffer has been closed.

Functions

func NewLogBuffer

func NewLogBuffer(logDriver logger.LogDriver, maxBytes int64) (logger.LogDriver, error)

NewLogBuffer return a new BufferLog.

Types

type LogBuffer

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

LogBuffer is uses to cache the container's logs with ringBuffer.

func (*LogBuffer) Close

func (bl *LogBuffer) Close() error

Close close the ringBuffer and drain the messages.

func (*LogBuffer) Name

func (bl *LogBuffer) Name() string

Name return the log driver's name.

func (*LogBuffer) WriteLogMessage

func (bl *LogBuffer) WriteLogMessage(msg *logger.LogMessage) error

WriteLogMessage will write the LogMessage to the ringBuffer.

type RingBuffer

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

RingBuffer implements a fixed-size buffer which will drop oldest data if full.

func NewRingBuffer

func NewRingBuffer(maxBytes int64) *RingBuffer

NewRingBuffer creates new RingBuffer.

func (*RingBuffer) Close

func (rb *RingBuffer) Close() error

Close closes the ringbuffer.

func (*RingBuffer) Drain

func (rb *RingBuffer) Drain() []*logger.LogMessage

Drain returns all the data in the buffer.

NOTE: it can be used after closed to make sure the data have been consumed.

func (*RingBuffer) Pop

func (rb *RingBuffer) Pop() (*logger.LogMessage, error)

Pop pops the value in the buffer.

NOTE: it returns ErrClosed if the buffer has been closed.

func (*RingBuffer) Push

func (rb *RingBuffer) Push(val *logger.LogMessage) error

Push pushes value into buffer and return whether it covers the oldest data or not.

Jump to

Keyboard shortcuts

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