logstore

package
v0.23.2 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

A central logstore.

Motivation and spec: https://github.com/tilt-dev/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 LineOptions added in v0.17.1

type LineOptions struct {
	ManifestNames  model.ManifestNameSet // only print logs for these manifests
	SuppressPrefix bool
}

type LogEvent

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

	// 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 LogLine added in v0.14.0

type LogLine struct {
	Text       string
	SpanID     SpanID
	ProgressID string

	// Most progress lines are optional. For example, if a bunch
	// of little upload updates come in, it's ok to skip some.
	//
	// ProgressMustPrint indicates that this line must appear in the
	// output - e.g., a line that communicates that the upload finished.
	ProgressMustPrint bool

	Time time.Time
}

type LogSegment

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

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

	// When we store warnings in the LogStore, we break them up into lines and
	// store them as a series of line segments. 'Anchor' marks the beginning of a
	// series of logs that should be kept together.
	//
	// Anchor warning1, line1
	//        warning1, line2
	// Anchor warning2, line1
	Anchor bool
}

func (LogSegment) CanContinueLine added in v0.10.25

func (l LogSegment) CanContinueLine(other LogSegment) bool

Whether these two log segments may be printed on the same line

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) ContinuingLines added in v0.14.0

func (s *LogStore) ContinuingLines(checkpoint Checkpoint) []LogLine

func (*LogStore) ContinuingLinesWithOptions added in v0.17.1

func (s *LogStore) ContinuingLinesWithOptions(checkpoint Checkpoint, opts LineOptions) []LogLine

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) ContinuingStringWithOptions added in v0.17.1

func (s *LogStore) ContinuingStringWithOptions(checkpoint Checkpoint, opts LineOptions) string

func (*LogStore) Empty

func (s *LogStore) Empty() bool

func (*LogStore) IsLastSegmentUncompleted added in v0.14.0

func (s *LogStore) IsLastSegmentUncompleted() 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) SpanLog added in v0.10.25

func (s *LogStore) SpanLog(spanID SpanID) string

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) TailSpan added in v0.10.25

func (s *LogStore) TailSpan(n int, spanID SpanID) string

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

func (*LogStore) ToLogList added in v0.10.24

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

func (*LogStore) Warnings added in v0.14.0

func (s *LogStore) Warnings(spanID SpanID) []string

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) ContinuingLines added in v0.14.0

func (r Reader) ContinuingLines(c Checkpoint) []LogLine

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

func (Reader) TailSpan added in v0.10.25

func (r Reader) TailSpan(n int, spanID SpanID) string

func (Reader) Warnings added in v0.14.0

func (r Reader) Warnings(spanID SpanID) []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 = model.LogSpanID

Jump to

Keyboard shortcuts

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