mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add link for viewing raw build logs in workspace and template build jobs (#21727)
* Adds support for parameter `format=text` in the following API routes: * `/api/v2/workspaceagents/:id/logs` * `/api/v2/workspacebuilds/:id/logs` * `/api/v2/templateversions/:id/logs` * `/api/v2/templateversions/:id/dry-run/:id/logs` * Adds links to view raw logs on the following pages: * Workspace build page * Template editor page * Template version page * Refactors existing log formatting in `cli/logs.go` to live in `codersdk`. 🤖 Generated with Claude Opus 4.5, reviewed by me. --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -217,6 +217,26 @@ type WorkspaceAgentLog struct {
|
||||
SourceID uuid.UUID `json:"source_id" format:"uuid"`
|
||||
}
|
||||
|
||||
// Text formats the log entry as human-readable text.
|
||||
func (l WorkspaceAgentLog) Text(agentName, sourceName string) string {
|
||||
var sb strings.Builder
|
||||
_, _ = sb.WriteString(l.CreatedAt.Format(time.RFC3339))
|
||||
_, _ = sb.WriteString(" [")
|
||||
_, _ = sb.WriteString(string(l.Level))
|
||||
_, _ = sb.WriteString("] [agent")
|
||||
if agentName != "" {
|
||||
_, _ = sb.WriteString(".")
|
||||
_, _ = sb.WriteString(agentName)
|
||||
}
|
||||
if sourceName != "" {
|
||||
_, _ = sb.WriteString("|")
|
||||
_, _ = sb.WriteString(sourceName)
|
||||
}
|
||||
_, _ = sb.WriteString("] ")
|
||||
_, _ = sb.WriteString(l.Output)
|
||||
return sb.String()
|
||||
}
|
||||
|
||||
type AgentSubsystem string
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user