Documentation
¶
Overview ¶
Package logs contains code to fetch logs from Kubernetes pods
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPodLogs ¶
func GetPodLogs( ctx context.Context, client kubernetes.Interface, pod v1.Pod, getPrevious bool, writer io.Writer, requestedLineLength int, ) ( []string, error, )
GetPodLogs streams the pod logs and shunts them to the `writer`, as well as returning the last `requestedLineLength` of lines of logs in a slice. If `getPrevious` was activated, it will get the previous logs
TODO: this function is a bit hacky. The K8s PodLogOptions have a field called `TailLines` that seems to be just what we would like. HOWEVER: we want the full logs too, so we can write them to a file, in addition to the `TailLines` we want to pass along for display
func TailPodLogs ¶ added in v1.18.1
func TailPodLogs( ctx context.Context, client kubernetes.Interface, pod v1.Pod, writer io.Writer, parseTimestamps bool, ) (err error)
TailPodLogs streams the pod logs starting from the current time, and keeps waiting for any new logs, until the context is cancelled by the calling process If `parseTimestamps` is true, the log line will have the timestamp in human-readable prepended. NOTE: this will make log-lines NON-JSON
Types ¶
type StreamingRequest ¶ added in v1.18.4
type StreamingRequest struct {
Pod *v1.Pod
Options *v1.PodLogOptions
Previous bool `json:"previous,omitempty"`
// contains filtered or unexported fields
}
StreamingRequest represents a request to stream a pod's logs