logstore

package
v0.10.23 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

A central logstore.

Motivation and spec: https://github.com/windmilleng/tilt.specs/pull/19

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SourcePrefix

func SourcePrefix(n model.ManifestName) string

Types

type Checkpoint

type Checkpoint int

An abstract checkpoint in the log store, so we can ask questions like "give me all logs since checkpoint X" and "scrub everything since checkpoint Y". In practice, this is just an index into the segment slice.

type LogEvent

type LogEvent interface {
	Message() []byte
	Time() time.Time

	// Ideally, all logs should be associated with a source.
	//
	// In practice, not all logs have an obvious source identifier,
	// so this might be empty.
	//
	// Right now, that source is a ManifestName. But in the future,
	// this might make more sense as another kind of identifier (like SpanID).
	//
	// (As of this writing, we have TargetID as an abstract build-time
	// source identifier, but no generic run-time source identifier)
	Source() model.ManifestName
}

type LogSegment

type LogSegment struct {
	SpanID SpanID
	Time   time.Time
	Text   []byte

	// Continues a line from a previous segment.
	ContinuesLine bool
}

func (LogSegment) IsComplete

func (l LogSegment) IsComplete() bool

func (LogSegment) Len

func (l LogSegment) Len() int

func (LogSegment) StartsLine

func (l LogSegment) StartsLine() bool

func (LogSegment) String

func (l LogSegment) String() string

type LogStore

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

A central place for storing logs. Not thread-safe.

If you need to read logs in a thread-safe way outside of the normal Store state loop, take a look at logstore.Reader.

func NewLogStore

func NewLogStore() *LogStore

func NewLogStoreForTesting

func NewLogStoreForTesting(msg string) *LogStore

func (*LogStore) Append

func (s *LogStore) Append(le LogEvent, secrets model.SecretSet)

func (*LogStore) Checkpoint

func (s *LogStore) Checkpoint() Checkpoint

func (*LogStore) ContinuingString

func (s *LogStore) ContinuingString(checkpoint Checkpoint) string

Returns logs incrementally from the given checkpoint.

In many use cases, logs are printed to an append-only stream (like os.Stdout). Once they've been printed, they can't be called back. ContinuingString() tries to make reasonable product decisions about printing all the logs that have streamed in since the given checkpoint.

Typical usage, looks like:

Print(store.ContinuingString(state.LastCheckpoint)) state.LastCheckpoint = store.Checkpoint()

func (*LogStore) Empty

func (s *LogStore) Empty() bool

func (*LogStore) ScrubSecretsStartingAt

func (s *LogStore) ScrubSecretsStartingAt(secrets model.SecretSet, checkpoint Checkpoint)

func (*LogStore) String

func (s *LogStore) String() string

func (*LogStore) Tail

func (s *LogStore) Tail(n int) string

Get at most N lines from the tail of the log.

type Reader

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

Thread-safe reading a log store, outside of the Store state loop.

func NewReader

func NewReader(mu *sync.RWMutex, store *LogStore) Reader

func (Reader) Checkpoint

func (r Reader) Checkpoint() Checkpoint

func (Reader) ContinuingString

func (r Reader) ContinuingString(c Checkpoint) string

func (Reader) String

func (r Reader) String() string

func (Reader) Tail

func (r Reader) Tail(n int) string

type Span

type Span struct {
	ManifestName     model.ManifestName
	LastSegmentIndex int
}

func (*Span) Clone

func (s *Span) Clone() *Span

type SpanID

type SpanID string

Jump to

Keyboard shortcuts

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