func (p *clientImpl) waitForLog(jobType, id string, peek bool) (io.ReadCloser, error) {
	var endpoint string
	switch jobType {
	case JobTypeSimulation:
		endpoint = endpoints.simulations.Log()
	case JobTypeDeployment:
		endpoint = endpoints.deployments.Log()
	default:
		endpoint = endpoints.builds.Log()
	}
	req := p.apiRequest(endpoint)
	req.param("id", id)

	resp, err := req.Do("GET", nil)
	if err != nil {
		return nil, err
	}

	if peek {
		// just verify that the server is streaming response
		// and pass over the remaining body
		var buf = make([]byte, 1)
		var err error
		for {
			_, err = resp.Body.Read(buf)
			if err != nil {
				break
			}
			if buf[0] != 0 {
				os.Stderr.Write(buf)
				break
			}
		}
		return resp.Body, err
	} else {
		defer resp.Body.Close()
		_, err = io.Copy(os.Stderr, resp.Body)
		return nil, err
	}
}
// waitForLog attempts to stream logs. If peek is true, it ensures log streaming has started
// and returns the body for the caller to read remaining contents.
// Otherwise, logs are streamed to stderr.
waitForLog attempts to stream logs. If peek is true, it ensures log streaming has started
and returns the body for the caller to read remaining contents.
Otherwise, logs are streamed to stderr.
// waitForLog attempts to stream logs . If peek is true it ensures log streaming has started // and returns the body for the caller to read remaining contents . // Otherwise logs are streamed to stderr .
func (p *clientImpl) waitForLog(jobType, id string, peek bool) (io.ReadCloser, error) {
	var endpoint string
	switch jobType {
	case JobTypeSimulation:
		endpoint = endpoints.simulations.Log()
	case JobTypeDeployment:
		endpoint = endpoints.deployments.Log()
	default:
		endpoint = endpoints.builds.Log()
	}
	req := p.apiRequest(endpoint)
	req.param("id", id)
	resp, err := req.Do("GET", nil)
	if err != nil {
		return nil, err
	}
	if peek {
		var buf = make([]byte, 1)
		var err error
		for {
			_, err = resp.Body.Read(buf)
			if err != nil {
				break
			}
			if buf[0] != 0 {
				os.Stderr.Write(buf)
				break
			}
		}
		return resp.Body, err
	} else {
		defer resp.Body.Close()
		_, err = io.Copy(os.Stderr, resp.Body)
		return nil, err
	}
}
func ( p * clientImpl ) waitForLog ( jobType , id string , peek bool ) ( io . ReadCloser , error ) { var endpoint string switch jobType { case JobTypeSimulation : endpoint = endpoints . simulations . Log ( ) case JobTypeDeployment : endpoint = endpoints . deployments . Log ( ) default : endpoint = endpoints . builds . Log ( ) } req := p . apiRequest ( endpoint ) req . param ( " " , id ) resp , err := req . Do ( " " , nil ) if err != nil { return nil , err } if peek { var buf = make ( [ ] byte , 1 ) var err error for { _ , err = resp . Body . Read ( buf ) if err != nil { break } if buf [ 0 ] != 0 { os . Stderr . Write ( buf ) break } } return resp . Body , err } else { defer resp . Body . Close ( ) _ , err = io . Copy ( os . Stderr , resp . Body ) return nil , err } }
waitForLog attempts to stream logs.
waitForLog attempts to stream logs .
// just verify that the server is streaming response // and pass over the remaining body