Skip to content

Stream build logs

client.Build.Logs(ctx, buildID) (*StreamChunk, error)
GET/v5/builds/{build_id}/logs

Stream a build’s logs as Server-Sent Events.

The response has content-type text/event-stream; each event carries one log line as an AgentexCloudBuildLogLine object, delivered as lines become available from the cloud build provider. The stream ends when the provider stops producing output. Responds with a not-found error if no such build exists for the caller’s account.

ParametersExpand Collapse
buildID string
ReturnsExpand Collapse
type StreamChunk struct{…}

A single log line from the build process.

Line string

The log line content

type StreamChunk struct{…}

A single log line from the build process.

Line string

The log line content

Stream build logs

package main

import (
  "context"
  "fmt"

  "github.com/scaleapi/sgp-dev-go"
  "github.com/scaleapi/sgp-dev-go/option"
)

func main() {
  client := sgpdev.NewClient(
    option.WithAPIKey("My API Key"),
    option.WithAccountID("My Account ID"),
  )
  stream := client.Build.LogsStreaming(context.TODO(), "build_id")
  for stream.Next() {
  fmt.Printf("%+v\n", stream.Current())
  }
  err := stream.Err()
  if err != nil {
    panic(err.Error())
  }
}
{
  "line": "line"
}
Returns Examples
{
  "line": "line"
}