tailer

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

node_logs.go extends the tailer with kubelet-proxy log streaming so torque can enrich 'torque logs' sessions with node/system files alongside pod output.

Package tailer implements torque's high-performance, color-aware log streamer used by the 'torque logs' family of commands, coordinating informers, filters, and observer hooks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultColorPalette

func DefaultColorPalette() []*color.Color

DefaultColorPalette returns the vibrant color rotation used when rendering torque log streams.

Types

type LogObserver

type LogObserver interface {
	ObserveLog(LogRecord)
}

LogObserver receives callbacks whenever the tailer renders a log line.

type LogRecord

type LogRecord struct {
	Timestamp          time.Time
	FormattedTimestamp string
	Namespace          string
	Pod                string
	Container          string
	Raw                string
	Rendered           string
	Source             string
	SourceGlyph        string
	RenderedEqualsRaw  bool
}

LogRecord captures a single log line emitted by the tailer along with contextual metadata.

type Option

type Option func(*Tailer)

Option configures optional Tailer behavior.

func WithJSONFilter

func WithJSONFilter(filters map[string]string) Option

WithJSONFilter sets key-value pairs to filter structured logs.

func WithLogObserver

func WithLogObserver(observer LogObserver) Option

WithLogObserver registers an observer that sees every rendered log line.

func WithOutput

func WithOutput(w io.Writer) Option

WithOutput overrides the writer used for rendered output.

func WithPodFilter

func WithPodFilter(filter func(*corev1.Pod) bool) Option

WithPodFilter registers an optional callback that further restricts which pods are tailed. It is evaluated after name/condition filters.

func WithSelectionObserver

func WithSelectionObserver(observer SelectionObserver) Option

WithSelectionObserver registers an observer that sees active selection changes (pods/containers tailed).

type SelectionObserver

type SelectionObserver interface {
	ObserveSelection(SelectionSnapshot)
}

SelectionObserver receives callbacks whenever the tailer changes its active selection.

type SelectionSnapshot

type SelectionSnapshot struct {
	Timestamp    time.Time         `json:"timestamp"`
	ChangeKind   string            `json:"changeKind"`
	Reason       string            `json:"reason,omitempty"`
	Namespace    string            `json:"namespace,omitempty"`
	Pod          string            `json:"pod,omitempty"`
	Container    string            `json:"container,omitempty"`
	RestartCount int32             `json:"restartCount,omitempty"`
	Selected     []SelectionTarget `json:"selected"`
}

SelectionSnapshot captures a change in the set of active log tails.

type SelectionTarget

type SelectionTarget struct {
	Namespace string `json:"namespace"`
	Pod       string `json:"pod"`
	Container string `json:"container"`
}

type Tailer

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

Tailer coordinates pod discovery via informers and streams logs to stdout.

func New

func New(client kubernetes.Interface, opts *config.Options, logger logr.Logger, tailerOptions ...Option) (*Tailer, error)

New creates a Tailer instance.

func (*Tailer) PruneTails

func (t *Tailer) PruneTails(keep func(namespace, pod, container string) bool, reason string)

PruneTails stops any active tails that do not satisfy keep.

func (*Tailer) Run

func (t *Tailer) Run(ctx context.Context) error

Run launches the tailer until the context is cancelled.

func (*Tailer) SetPodDisplayOverride

func (t *Tailer) SetPodDisplayOverride(namespace, pod, display string)

SetPodDisplayOverride overrides the rendered pod label for the given pod. The override affects only output formatting, not Kubernetes API requests.

Jump to

Keyboard shortcuts

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