logstore

package
v0.10.24 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2019 License: Apache-2.0 Imports: 8 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

	// The manifest that this log is associated with.
	ManifestName() model.ManifestName

	// The SpanID that identifies what Span this is associated with in the LogStore.
	SpanID() SpanID
}

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) ManifestLog added in v0.10.24

func (s *LogStore) ManifestLog(mn model.ManifestName) string

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.

func (*LogStore) ToLogList added in v0.10.24

func (s *LogStore) ToLogList() (*webview.LogList, error)

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) Empty added in v0.10.24

func (r Reader) Empty() bool

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
	FirstSegmentIndex 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