streamlog

package
v3.0.0-rc77 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 18 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTimeSpec is the error of a since or until that is not a time,
	// or of a since after the until: the window can not be read.
	ErrTimeSpec = errors.New("invalid time")

	// ErrFollowUntil is the error of a follow bounded by an until:
	// journalctl -f ignores --until, and would follow past it.
	ErrFollowUntil = errors.New("until can not be used with follow")
)
View Source
var ErrGrepUnsupported = errors.New("--grep: unsupported by this journalctl (systemd < 237 or built without PCRE2)")

ErrGrepUnsupported is the error of a read filtering on a pattern where journalctl has no --grep: a journalctl older than systemd 237, or built without PCRE2, as rhel7's. The read used to answer no line, as if none matched.

Functions

func ParseTime

func ParseTime(s string, now time.Time) (time.Time, error)

ParseTime returns the time of a since or an until: a negative duration before now, "-1h" an hour ago, or a RFC3339 time, "2026-12-02T10:00:00Z" or "2026-12-02T10:00:00+01:00". Empty is the zero time, no bound. A positive duration is refused: "1h" would read as an hour ago or in an hour.

func ParseWindow

func ParseWindow(since, until string, now time.Time) (time.Time, time.Time, error)

ParseWindow returns the times of a since and an until, as ParseTime does, and refuses a since after the until.

Types

type Event

type Event struct {
	B []byte
	M map[string]any
}

func NewEvent

func NewEvent(b []byte) (Event, error)

func (*Event) IsZero

func (event *Event) IsZero() bool

func (*Event) Map

func (event *Event) Map() map[string]any

func (*Event) Render

func (event *Event) Render(format string)

func (*Event) RenderConsole

func (event *Event) RenderConsole()

func (*Event) RenderData

func (event *Event) RenderData()

type Events

type Events []Event

func (Events) MatchString

func (events Events) MatchString(key, pattern string) bool

func (Events) Render

func (events Events) Render(format string)

func (Events) RenderConsole

func (events Events) RenderConsole()

func (Events) RenderData

func (events Events) RenderData()

func (Events) Sort

func (events Events) Sort()

type Stream

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

func NewStream

func NewStream() *Stream

func (*Stream) Errors

func (stream *Stream) Errors() chan error

func (*Stream) Events

func (stream *Stream) Events() chan Event

func (*Stream) Start

func (stream *Stream) Start(streamConfig StreamConfig) error

Start starts the read of the config. A config journalctl would not read as asked is refused before anything is sent: ErrFollowUntil, ErrTimeSpec for a since after the until, ErrGrepUnsupported.

func (*Stream) Stop

func (stream *Stream) Stop() error

type StreamConfig

type StreamConfig struct {
	Follow bool

	// Lines is the number of the last entries read. With Since or
	// Until set, it is the last entries of their window, every entry
	// of it when 0 or less.
	Lines int

	Matches []string
	Grep    *string

	// Since and Until bound the entries read to a window, as
	// ParseTime returns them. The zero time is no bound. Until is
	// refused with Follow, which journalctl would ignore.
	Since time.Time
	Until time.Time
}

Jump to

Keyboard shortcuts

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