MCPcopy Index your code
hub / github.com/coder/coder / TaskLogs

Method TaskLogs

codersdk/aitasks.go:406–423  ·  view source on GitHub ↗

TaskLogs retrieves logs from the task app.

(ctx context.Context, user string, id uuid.UUID)

Source from the content-addressed store, hash-verified

404
405// TaskLogs retrieves logs from the task app.
406func (c *Client) TaskLogs(ctx context.Context, user string, id uuid.UUID) (TaskLogsResponse, error) {
407 res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/tasks/%s/%s/logs", user, id.String()), nil)
408 if err != nil {
409 return TaskLogsResponse{}, err
410 }
411 defer res.Body.Close()
412
413 if res.StatusCode != http.StatusOK {
414 return TaskLogsResponse{}, ReadBodyAsError(res)
415 }
416
417 var logs TaskLogsResponse
418 if err := json.NewDecoder(res.Body).Decode(&logs); err != nil {
419 return TaskLogsResponse{}, xerrors.Errorf("decoding task logs response: %w", err)
420 }
421
422 return logs, nil
423}

Callers 3

TestTasksFunction · 0.80
toolsdk.goFile · 0.80
taskLogsMethod · 0.80

Calls 5

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
CloseMethod · 0.65
StringMethod · 0.45
ErrorfMethod · 0.45

Tested by 1

TestTasksFunction · 0.64