podlogs

package
v1.28.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package podlogs contains code to fetch logs from Kubernetes pods

Index

Constants

View Source
const DefaultFollowWaiting time.Duration = 1 * time.Second

DefaultFollowWaiting is the default time the cluster streaming should wait before searching again for new cluster pods

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterWriter

type ClusterWriter struct {
	Cluster       *apiv1.Cluster
	Options       *corev1.PodLogOptions
	Previous      bool `json:"previous,omitempty"`
	FollowWaiting time.Duration
	// NOTE: the Client argument may be omitted, but it is good practice to pass it
	// Importantly, it makes the logging functions testable
	Client kubernetes.Interface
}

ClusterWriter represents a request to stream a cluster's pod logs.

If the Follow Option is set to true, streaming will sit in a loop looking for any new / regenerated pods and will only exit when there are no pods streaming

func (*ClusterWriter) SingleStream

func (csr *ClusterWriter) SingleStream(ctx context.Context, writer io.Writer) error

SingleStream streams the cluster's pod logs and shunts them to a single io.Writer

type Writer

type Writer struct {
	Pod    corev1.Pod
	Client kubernetes.Interface
}

Writer represents a request to stream a pod's logs and send them to an io.Writer

func NewPodLogsWriter

func NewPodLogsWriter(pod corev1.Pod, cli kubernetes.Interface) *Writer

NewPodLogsWriter initializes the struct

func (*Writer) Multiple

func (spl *Writer) Multiple(
	ctx context.Context,
	opts *corev1.PodLogOptions,
	writerConstructor writerConstructor,
	filePathGenerator func(string) string,
) error

Multiple streams the pod logs, sending each container's stream to a separate writer

func (*Writer) Single

func (spl *Writer) Single(ctx context.Context, writer io.Writer, opts *corev1.PodLogOptions) (err error)

Single streams the pod logs and shunts them to the `writer`. If there are multiple containers, it will concatenate all the container streams into the writer

Jump to

Keyboard shortcuts

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