refactor(logs): update log formatting for systemd services and handle merging in the client

This commit is contained in:
Pasha Sviderski
2026-04-21 22:00:38 +10:00
parent 7e1b91c372
commit b852d34068
5 changed files with 140 additions and 88 deletions
+5 -3
View File
@@ -57,14 +57,15 @@ type ServiceLogsOptions struct {
Machines []string
}
// ServiceLogEntry represents a single log entry from a service container.
// ServiceLogEntry represents a single log entry from a service container or systemd service.
type ServiceLogEntry struct {
// Metadata may not be set if an error occurred (Err is not nil).
Metadata ServiceLogEntryMetadata
LogEntry
}
// ServiceLogEntryMetadata contains metadata about the source of a log entry.
// ServiceLogEntryMetadata identifies the source of a log entry.
// For systemd service logs, ServiceID and ServiceName hold the unit name and ContainerID is empty.
type ServiceLogEntryMetadata struct {
ServiceID string
ServiceName string
@@ -77,7 +78,8 @@ type ServiceLogEntryMetadata struct {
type LogEntry struct {
Stream LogStreamType
Timestamp time.Time
Message []byte
// Message is the raw log line as bytes terminated with a trailing newline.
Message []byte
// Err indicates that an error occurred while streaming logs from a container.
// Other fields are not set if Err is not nil.
Err error