mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
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:
+4
-4
@@ -79,7 +79,7 @@ type Client interface {
|
||||
PostAppHealth(ctx context.Context, req agentsdk.PostAppHealthsRequest) error
|
||||
PostStartup(ctx context.Context, req agentsdk.PostStartupRequest) error
|
||||
PostMetadata(ctx context.Context, key string, req agentsdk.PostMetadataRequest) error
|
||||
PatchStartupLogs(ctx context.Context, req agentsdk.PatchStartupLogs) error
|
||||
PatchLogs(ctx context.Context, req agentsdk.PatchLogs) error
|
||||
GetServiceBanner(ctx context.Context) (codersdk.ServiceBannerConfig, error)
|
||||
}
|
||||
|
||||
@@ -1006,7 +1006,7 @@ func (a *agent) runScript(ctx context.Context, lifecycle, script string) (err er
|
||||
|
||||
var stdout, stderr io.Writer = fileWriter, fileWriter
|
||||
if lifecycle == "startup" {
|
||||
send, flushAndClose := agentsdk.StartupLogsSender(a.client.PatchStartupLogs, logger)
|
||||
send, flushAndClose := agentsdk.LogsSender(a.client.PatchLogs, logger)
|
||||
// If ctx is canceled here (or in a writer below), we may be
|
||||
// discarding logs, but that's okay because we're shutting down
|
||||
// anyway. We could consider creating a new context here if we
|
||||
@@ -1017,9 +1017,9 @@ func (a *agent) runScript(ctx context.Context, lifecycle, script string) (err er
|
||||
}
|
||||
}()
|
||||
|
||||
infoW := agentsdk.StartupLogsWriter(ctx, send, codersdk.LogLevelInfo)
|
||||
infoW := agentsdk.StartupLogsWriter(ctx, send, codersdk.WorkspaceAgentLogSourceStartupScript, codersdk.LogLevelInfo)
|
||||
defer infoW.Close()
|
||||
errW := agentsdk.StartupLogsWriter(ctx, send, codersdk.LogLevelError)
|
||||
errW := agentsdk.StartupLogsWriter(ctx, send, codersdk.WorkspaceAgentLogSourceStartupScript, codersdk.LogLevelError)
|
||||
defer errW.Close()
|
||||
|
||||
stdout = io.MultiWriter(fileWriter, infoW)
|
||||
|
||||
@@ -55,7 +55,7 @@ type Client struct {
|
||||
mu sync.Mutex // Protects following.
|
||||
lifecycleStates []codersdk.WorkspaceAgentLifecycle
|
||||
startup agentsdk.PostStartupRequest
|
||||
logs []agentsdk.StartupLog
|
||||
logs []agentsdk.Log
|
||||
derpMapUpdates chan agentsdk.DERPMapUpdate
|
||||
}
|
||||
|
||||
@@ -161,13 +161,13 @@ func (c *Client) PostStartup(ctx context.Context, startup agentsdk.PostStartupRe
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) GetStartupLogs() []agentsdk.StartupLog {
|
||||
func (c *Client) GetStartupLogs() []agentsdk.Log {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
return c.logs
|
||||
}
|
||||
|
||||
func (c *Client) PatchStartupLogs(ctx context.Context, logs agentsdk.PatchStartupLogs) error {
|
||||
func (c *Client) PatchLogs(ctx context.Context, logs agentsdk.PatchLogs) error {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
if c.PatchWorkspaceLogs != nil {
|
||||
|
||||
Reference in New Issue
Block a user