iolog

package
v1.4.3-dev Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RFC3339NanoFixed is Docker's version of RFC339Nano that pads the
	// nanoseconds with zeros to ensure that the timestamps are aligned in the logs.
	RFC3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock interface {
	Now() time.Time
}

Clock defines an interface that wraps time.Now()

type Entry

type Entry struct {
	Header
	Message []byte
}

Entry describes a containerVM log entry

func ParseLogEntry

func ParseLogEntry(r io.Reader) (*Entry, error)

ParseLogEntry parses data from an io.Reader into a Entry

type Header struct {
	Timestamp time.Time
	Size      int
	Stream    int
}

Header describes the header of a containerVM log entry

type LogClock

type LogClock struct{}

LogClock is an implementation of the Clock interface that returns time.Now() for use in the iolog package

func (LogClock) Now

func (LogClock) Now() time.Time

Now returns the local time time.Now()

type LogReader

type LogReader struct {
	io.ReadCloser
	// contains filtered or unexported fields
}

LogReader reads containerVM entries from a stream and decodes them into their original form

func NewLogReader

func NewLogReader(r io.ReadCloser, ts bool) *LogReader

NewLogReader wraps an io.ReadCloser in a LogReader.

func (*LogReader) Read

func (lr *LogReader) Read(p []byte) (int, error)

Read reads a 10 byte header and decodes it into the timestamp, stream and size of an entry. It uses the size to read the next set of bytes as the message, and then copies the message into the supplied buffer, saving what will not fit in the buffer for the next call to Read.

type LogWriter

type LogWriter struct {
	Clock
	// contains filtered or unexported fields
}

LogWriter tags log entries with a descriptive header and writes them to the underlying io.Writer

func NewLogWriter

func NewLogWriter(w io.Writer, clock Clock) *LogWriter

NewLogWriter wraps an io.WriteCloser in a LogWriter

func (*LogWriter) Close

func (lw *LogWriter) Close() (err error)

Close will flush the remaining bytes that have not yet been written

func (*LogWriter) Write

func (lw *LogWriter) Write(p []byte) (n int, err error)

Write scans the supplied buffer, breaking off indvidual entries and writing them to the underlying Writer, flushing any leftover bytes

Jump to

Keyboard shortcuts

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