MCPcopy
hub / github.com/cli/cli / GetLog

Method GetLog

pkg/cmd/run/view/logs.go:40–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

38}
39
40func (f *apiLogFetcher) GetLog() (io.ReadCloser, error) {
41 logURL := fmt.Sprintf("%srepos/%s/actions/jobs/%d/logs",
42 ghinstance.RESTPrefix(f.repo.RepoHost()), ghrepo.FullName(f.repo), f.jobID)
43
44 req, err := http.NewRequest("GET", logURL, nil)
45 if err != nil {
46 return nil, err
47 }
48
49 resp, err := f.httpClient.Do(req)
50 if err != nil {
51 return nil, err
52 }
53
54 if resp.StatusCode == 404 {
55 return nil, fmt.Errorf("log not found: %v", f.jobID)
56 } else if resp.StatusCode != 200 {
57 return nil, api.HandleHTTPError(resp)
58 }
59
60 return resp.Body, nil
61}
62
63// logSegment represents a segment of a log trail, which can be either an entire
64// job log or an individual step log.

Callers 1

TestApiLogFetcherFunction · 0.95

Calls 6

RESTPrefixFunction · 0.92
FullNameFunction · 0.92
HandleHTTPErrorFunction · 0.92
RepoHostMethod · 0.65
DoMethod · 0.65
ErrorfMethod · 0.65

Tested by 1

TestApiLogFetcherFunction · 0.76