Documentation ¶
Index ¶
- func Stream(stop <-chan struct{}, podsClient typedcorev1.PodInterface, options ...Option) error
- type LogEntry
- type LogEntryConsumer
- type LogEntryConsumerFunc
- type LogEntryConsumers
- type LogFilter
- type LogFilterFunc
- type Option
- func ConsumeLogsWith(first LogEntryConsumer, other ...LogEntryConsumer) Option
- func ConsumeLogsWithFunc(first LogEntryConsumerFunc) Option
- func FilterWithRegex(expr string) Option
- func FollowSelectedPods(labelSelector string) Option
- func FromContainer(containerName string) Option
- func FromSelectedPods(labelSelector string) Option
- func WithLogger(logger kubekit.Logger) Option
- type Streamer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Stream ¶
func Stream( stop <-chan struct{}, podsClient typedcorev1.PodInterface, options ...Option, ) error
Stream starts the pod stream. It stops when the stop channel returned, or any terminal error occurs, or all pods logs have been consumed in non-follow mode.
The implemenetation is based on https://github.com/argoproj/argo-workflows/blob/8c77e89fc185ff640e1073692dfc7c043037440a/util/logs/workflow-logger.go .
Types ¶
type LogEntry ¶
type LogEntry struct { // Time is the log time. Time time.Time `json:"time"` // Log is the log message. Log string `json:"log"` }
LogEntry represents a single log entry.
type LogEntryConsumer ¶
type LogEntryConsumer interface { // OnLogs is called when new logs are available. OnLogs(logs []LogEntry) }
LogEntryConsumer consumes log entries.
type LogEntryConsumerFunc ¶
type LogEntryConsumerFunc func(logs []LogEntry)
LogEntryConsumerFunc is a function that consumes log entries.
func (LogEntryConsumerFunc) OnLogs ¶
func (f LogEntryConsumerFunc) OnLogs(logs []LogEntry)
type LogEntryConsumers ¶
type LogEntryConsumers []LogEntryConsumer
LogEntryConsumers combines a group of LogEntryConsumer. Each consumer is called one by one with with the slice order.
func (LogEntryConsumers) OnLogs ¶
func (s LogEntryConsumers) OnLogs(logs []LogEntry)
type LogFilter ¶
type LogFilter interface { // FilterLog returns true if the log line should be consumed. FilterLog(log string) bool }
LogFilter filters log line.
type LogFilterFunc ¶
LogFilterFunc is a LogFilter that implements the FilterLog method.
func (LogFilterFunc) FilterLog ¶
func (f LogFilterFunc) FilterLog(log string) bool
type Option ¶
Option specifies options for configuring the podstream reader.
func ConsumeLogsWith ¶
func ConsumeLogsWith(first LogEntryConsumer, other ...LogEntryConsumer) Option
ConsumeLogsWithFunc sets the log consumer to use.
func ConsumeLogsWithFunc ¶
func ConsumeLogsWithFunc(first LogEntryConsumerFunc) Option
ConsumeLogsWithFunc sets the log consumer to use with function.
func FilterWithRegex ¶
FilterWithRegex filters the logs with the given regex.
func FollowSelectedPods ¶
FollowSelectedPods sets the pod label selector and follow flag. It follows the log streamming until caller stops it.
func FromContainer ¶
FromContainer sets the container name to log from.
func FromSelectedPods ¶
FromSelectedPods sets the label selector. It stops the streamer after all logs have been consumed.
func WithLogger ¶
WithLogger sets the logger to be used by the streamer.