diff --git a/internal/cloudfoundry/stage.go b/internal/cloudfoundry/stage.go index 912572f..cee76d1 100644 --- a/internal/cloudfoundry/stage.go +++ b/internal/cloudfoundry/stage.go @@ -35,6 +35,21 @@ func (s Stage) Run(logs io.Writer, home, name string) (string, error) { Env: env, }) if err != nil { + // In CF API v3, staging failure logs are not automatically captured in stdout/stderr + // We need to fetch them explicitly using 'cf logs --recent' + recentLogs := bytes.NewBuffer(nil) + logErr := s.cli.Execute(pexec.Execution{ + Args: []string{"logs", name, "--recent"}, + Stdout: recentLogs, + Stderr: recentLogs, + Env: env, + }) + if logErr == nil && recentLogs.Len() > 0 { + // Append recent logs to the main logs buffer + _, _ = logs.Write([]byte("\n--- Recent Logs (cf logs --recent) ---\n")) + _, _ = logs.Write(recentLogs.Bytes()) + } + return "", fmt.Errorf("failed to start: %w\n\nOutput:\n%s", err, logs) }