source

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrFileTruncated semerr.Error = "file truncated"
)
View Source
const (

	// RefreshInterval is an interval of refreshing logs.
	RefreshInterval = 200 * time.Millisecond
)

Variables

This section is empty.

Functions

This section is empty.

Types

type LazyLogEntries added in v0.4.0

type LazyLogEntries struct {
	Seeker  *os.File
	Entries []LazyLogEntry
}

LazyLogEntries is a helper type definition for the slice of lazy log entries.

func (LazyLogEntries) Filter added in v0.4.0

func (entries LazyLogEntries) Filter(term string) (LazyLogEntries, error)

Filter filters entries by ignore case exact match.

func (LazyLogEntries) Len added in v1.0.0

func (entries LazyLogEntries) Len() int

func (LazyLogEntries) Row added in v1.0.0

func (entries LazyLogEntries) Row(cfg *config.Config, i int) table.Row

Row returns table.Row representation of the log entry.

type LazyLogEntry added in v0.4.0

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

LazyLogEntry holds unredenred LogEntry. Use `LogEntry` getter.

func (LazyLogEntry) Length added in v1.0.0

func (e LazyLogEntry) Length() int

Length of the entry.

func (LazyLogEntry) Line added in v0.4.0

func (e LazyLogEntry) Line(file *os.File) (json.RawMessage, error)

Line re-reads the line.

func (LazyLogEntry) LogEntry added in v0.4.0

func (e LazyLogEntry) LogEntry(file *os.File, cfg *config.Config) LogEntry

LogEntry parses and returns `LogEntry`.

type Level

type Level string

Level of the logs entity.

const (
	LevelUnknown Level = "none"
	LevelTrace   Level = "trace"
	LevelDebug   Level = "debug"
	LevelInfo    Level = "info"
	LevelWarning Level = "warn"
	LevelError   Level = "error"
	LevelPanic   Level = "panic"
	LevelFatal   Level = "fatal"
)

Possible log levels.

func ParseLevel added in v0.1.1

func ParseLevel(value string, customMapping map[string]string) Level

ParseLevel parses level from the text value.

nolint: cyclop // Switch-case.

func (Level) String

func (l Level) String() string

String implement fmt.Stringer interface.

type LogEntry

type LogEntry struct {
	Fields []string
	Line   json.RawMessage
	Error  error
}

LogEntry is a single partly-parse record of the log.

func (LogEntry) Row

func (e LogEntry) Row() table.Row

Row returns table.Row representation of the log entry.

type Source added in v1.0.0

type Source struct {
	// Seeker is used to do random access reads from the file.
	Seeker *os.File
	// contains filtered or unexported fields
}

func File added in v1.0.0

func File(name string, cfg *config.Config) (*Source, error)

File creates a new Source for reading log entries from a file.

func Reader added in v1.0.0

func Reader(input io.Reader, cfg *config.Config) (*Source, error)

Reader creates a new Source for reading log entries from an io.Reader. This will write the input to a temp file, which will be used to seek against.

func (*Source) CanFollow added in v1.0.0

func (s *Source) CanFollow() bool

func (*Source) Close added in v1.0.0

func (s *Source) Close() error

Close implements io.Closer.

It closes and removes temporary files.

func (*Source) ParseLogEntries added in v1.0.0

func (s *Source) ParseLogEntries() (LazyLogEntries, error)

func (*Source) StartStreaming added in v1.0.0

func (s *Source) StartStreaming(ctx context.Context, send func(msg LazyLogEntries, err error))

StartStreaming synchronizes log entries with the file and sends them to the channel.

Jump to

Keyboard shortcuts

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