MCPcopy Index your code
hub / github.com/cli/cli / Follow

Method Follow

pkg/cmd/agent-task/shared/log.go:31–54  ·  view source on GitHub ↗

Follow continuously fetches logs using the provided fetcher function and renders them to the provided writer. It stops when Render indicates to stop.

(fetcher func() ([]byte, error), w io.Writer, io *iostreams.IOStreams)

Source from the content-addressed store, hash-verified

29// Follow continuously fetches logs using the provided fetcher function and
30// renders them to the provided writer. It stops when Render indicates to stop.
31func (r *logRenderer) Follow(fetcher func() ([]byte, error), w io.Writer, io *iostreams.IOStreams) error {
32 var last string
33 for {
34 raw, err := fetcher()
35 if err != nil {
36 return err
37 }
38
39 logs := string(raw)
40 if logs == last {
41 continue
42 }
43
44 diff := strings.TrimSpace(logs[len(last):])
45
46 if stop, err := r.Render([]byte(diff), w, io); err != nil {
47 return err
48 } else if stop {
49 return nil
50 }
51
52 last = logs
53 }
54}
55
56// Render processes the given logs and writes the rendered output to w.
57// Errors are returned when an unexpected log entry is encountered.

Callers

nothing calls this directly

Calls 2

RenderMethod · 0.95
fetcherStruct · 0.85

Tested by

no test coverage detected