MCPcopy Create free account
hub / github.com/devspace-sh/devspace / StartLogsWithWriter

Function StartLogsWithWriter

pkg/devspace/services/logs/logs.go:16–30  ·  view source on GitHub ↗

StartLogsWithWriter prints the logs and then attaches to the container with the given stdout and stderr

(ctx devspacecontext.Context, selector targetselector.TargetSelector, follow bool, tail int64, writer io.Writer)

Source from the content-addressed store, hash-verified

14
15// StartLogsWithWriter prints the logs and then attaches to the container with the given stdout and stderr
16func StartLogsWithWriter(ctx devspacecontext.Context, selector targetselector.TargetSelector, follow bool, tail int64, writer io.Writer) error {
17 container, err := selector.SelectSingleContainer(ctx.Context(), ctx.KubeClient(), ctx.Log())
18 if err != nil {
19 return err
20 }
21
22 ctx.Log().Infof("Printing logs of pod:container %s:%s", ansi.Color(container.Pod.Name, "white+b"), ansi.Color(container.Container.Name, "white+b"))
23 reader, err := ctx.KubeClient().Logs(ctx.Context(), container.Pod.Namespace, container.Pod.Name, container.Container.Name, false, &tail, follow)
24 if err != nil {
25 return err
26 }
27
28 _, err = io.Copy(writer, reader)
29 return err
30}
31
32// StartLogs print the logs and then attaches to the container
33func StartLogs(

Callers 1

RunLogsMethod · 0.92

Calls 7

SelectSingleContainerMethod · 0.65
ContextMethod · 0.65
KubeClientMethod · 0.65
LogMethod · 0.65
LogsMethod · 0.65
CopyMethod · 0.65
InfofMethod · 0.45

Tested by

no test coverage detected