diff --git a/internal/cli/logs/formatter.go b/internal/cli/logs/formatter.go index 87f3e4fc..31f85de0 100644 --- a/internal/cli/logs/formatter.go +++ b/internal/cli/logs/formatter.go @@ -82,7 +82,7 @@ func (f *Formatter) formatMachine(name string) string { return style.Render(name) } -func (f *Formatter) formatService(serviceName, containerID string) string { +func (f *Formatter) formatService(serviceName, containerID, hook string) string { styleService := lipgloss.NewStyle().Bold(true) padding := f.maxServiceWidth - len(serviceName) @@ -102,7 +102,11 @@ func (f *Formatter) formatService(serviceName, containerID string) string { return styleService.PaddingRight(padding).Render(serviceName) } - return styleService.Render(serviceName) + tui.Faint.PaddingRight(padding).Render("/"+containerID[:5]) + out := styleService.Render(serviceName) + tui.Faint.PaddingRight(padding).Render("/"+containerID[:5]) + if hook != "" { + out += tui.Faint.Render(" [" + hook + "]") + } + return out } // PrintEntry prints a single log entry with proper formatting. @@ -126,7 +130,7 @@ func (f *Formatter) PrintEntry(entry api.ServiceLogEntry) { output.WriteString(" ") // Service/container_id or service name for a systemd service. - output.WriteString(f.formatService(entry.Metadata.ServiceName, entry.Metadata.ContainerID)) + output.WriteString(f.formatService(entry.Metadata.ServiceName, entry.Metadata.ContainerID, entry.Metadata.Hook)) output.WriteString(" ") // Message diff --git a/pkg/api/logs.go b/pkg/api/logs.go index 2ac15db1..b52badee 100644 --- a/pkg/api/logs.go +++ b/pkg/api/logs.go @@ -76,6 +76,8 @@ type ServiceLogEntryMetadata struct { ContainerID string MachineID string MachineName string + // Hook is the hook type of the source container (e.g., "pre-deploy"). Empty for non-hook containers. + Hook string } // LogEntry represents a single log entry from a container or a service. diff --git a/pkg/client/logs.go b/pkg/client/logs.go index cdadb903..bcaecab5 100644 --- a/pkg/client/logs.go +++ b/pkg/client/logs.go @@ -81,6 +81,7 @@ func (cli *Client) ServiceLogs( ContainerID: ctr.Container.ID, MachineID: ctr.MachineID, MachineName: machineName, + Hook: ctr.Container.Config.Labels[api.LabelHook], } enrichedStream := logsStreamWithServiceMetadata(stream, metadata) ctrStreams = append(ctrStreams, enrichedStream)