Documentation
¶
Overview ¶
Package logs provides a shared log printer for CLI commands that consume enriched log events from the job-scoped SSE stream. The `ploy job follow` command delegates to this printer to ensure consistent formatting across all log-consuming commands.
This package uses the canonical stream.LogRecord type from internal/stream to ensure a single source of truth for log payload structures across the server publish path and CLI decode path. This eliminates duplicate struct definitions and prevents drift between server and CLI.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Printer formats and writes log records to an output stream. Thread-safe for use in SSE event handlers.
func NewPrinter ¶
NewPrinter creates a log printer with the given format and output writer. If format is empty, defaults to FormatStructured. If out is nil, logs are discarded silently.
func (*Printer) PrintLog ¶
PrintLog formats and writes a single log record.
Structured format (when enriched fields are present):
2025-10-22T10:00:00Z stdout node=<node_id> job_type=<job_type> step=<next_id> job=<job_id> Step started
Structured format (basic, no enriched fields):
2025-10-22T10:00:00Z stdout Step started
Raw format (message only):
Step started
func (*Printer) PrintRetentionSummary ¶
func (p *Printer) PrintRetentionSummary()
PrintRetentionSummary outputs the stored retention hint, if any. Call this after all log events have been processed.
func (*Printer) RecordRetention ¶
func (p *Printer) RecordRetention(hint logstream.RetentionHint)
RecordRetention stores a retention hint to be printed at stream completion. Only the last recorded hint is printed (calls overwrite previous hints).