chore: rename startup logs to agent logs (#8649)

* chore: rename startup logs to agent logs

This also adds a `source` property to every agent log. It
should allow us to group logs and display them nicer in
the UI as they stream in.

* Fix migration order

* Fix naming

* Rename the frontend

* Fix tests

* Fix down migration

* Match enums for workspace agent logs

* Fix inserting log source

* Fix migration order

* Fix logs tests

* Fix psql insert
This commit is contained in:
Kyle Carberry
2023-07-28 09:57:23 -06:00
committed by GitHub
parent 78b06397a6
commit bd944e0d21
48 changed files with 1471 additions and 876 deletions

View File

@ -167,7 +167,7 @@ func main() {
Use: "agent",
Handler: func(inv *clibase.Invocation) error {
var agent codersdk.WorkspaceAgent
var logs []codersdk.WorkspaceAgentStartupLog
var logs []codersdk.WorkspaceAgentLog
fetchSteps := []func(){
func() {
@ -191,7 +191,7 @@ func main() {
if rand.Float64() > 0.75 { //nolint:gosec
level = codersdk.LogLevelError
}
logs = append(logs, codersdk.WorkspaceAgentStartupLog{
logs = append(logs, codersdk.WorkspaceAgentLog{
CreatedAt: time.Now().Add(-time.Duration(10-i) * 144 * time.Millisecond),
Output: fmt.Sprintf("Some log %d", i),
Level: level,
@ -226,13 +226,13 @@ func main() {
step()
return agent, nil
},
FetchLogs: func(_ context.Context, _ uuid.UUID, _ int64, follow bool) (<-chan []codersdk.WorkspaceAgentStartupLog, io.Closer, error) {
logsC := make(chan []codersdk.WorkspaceAgentStartupLog, len(logs))
FetchLogs: func(_ context.Context, _ uuid.UUID, _ int64, follow bool) (<-chan []codersdk.WorkspaceAgentLog, io.Closer, error) {
logsC := make(chan []codersdk.WorkspaceAgentLog, len(logs))
if follow {
go func() {
defer close(logsC)
for _, log := range logs {
logsC <- []codersdk.WorkspaceAgentStartupLog{log}
logsC <- []codersdk.WorkspaceAgentLog{log}
time.Sleep(144 * time.Millisecond)
}
agent.LifecycleState = codersdk.WorkspaceAgentLifecycleReady