logs

package
v0.64.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildHostSink added in v0.56.0

func BuildHostSink(service string, mode SinkMode, stdout, stderr io.Writer, color bool, redactor *SecretRedactor) (outW, errW io.Writer, closeFn func() error, err error)

BuildHostSink is like BuildSink but returns separate stdout and stderr writers. A host child process is the only producer with distinct stdout/stderr streams; in raw mode (the host default) its stderr must stay on os.Stderr to preserve today's behavior (e.g. `devx up 2>err.log`). In prefixed mode both streams share one mutex-guarded LineWriter (the unified inline view); in off mode both are file-only. The same log file backs both writers.

func BuildSink added in v0.56.0

func BuildSink(service string, mode SinkMode, inline io.Writer, color bool, redactor *SecretRedactor) (io.Writer, func() error, error)

BuildSink returns the writer a producer should write log bytes to, plus a closer. It always writes the service's log file (the devx-logs fan-out) and, per mode, also writes inline (raw or prefixed) to the provided inline writer (normally os.Stdout). color toggles ANSI for the prefixed mode; redactor may be nil. For LogOffMode the inline writer is omitted (file only).

func ColorEnabled added in v0.56.0

func ColorEnabled() bool

ColorEnabled reports whether inline log prefixes should be colored. Disabled when NO_COLOR is set (https://no-color.org). Callers pass the result to NewLineWriter.

func OpenServiceLog added in v0.56.0

func OpenServiceLog(service string) (*os.File, error)

OpenServiceLog creates/truncates the per-service log file (fresh per `up` run).

func ServiceLogPath added in v0.56.0

func ServiceLogPath(service string) string

ServiceLogPath is the per-service log file path consumed by `devx logs`.

func TailContainerCrashLogs added in v0.25.0

func TailContainerCrashLogs(runtime, containerName string, lines int)

TailContainerCrashLogs fetches the last N lines from a crashed container and prints them in a styled error box for immediate developer context.

func TailHostCrashLogs added in v0.25.0

func TailHostCrashLogs(serviceName string, lines int)

TailHostCrashLogs reads the last N lines from a host process log file and prints them in a styled error box.

Types

type ColorPicker added in v0.56.0

type ColorPicker struct {
	// contains filtered or unexported fields
}

ColorPicker assigns a stable lipgloss color to each service name, cycling through the palette. Safe for concurrent use.

func NewColorPicker added in v0.56.0

func NewColorPicker() *ColorPicker

func (*ColorPicker) Color added in v0.56.0

func (p *ColorPicker) Color(service string) lipgloss.Color

Color returns the (stable) color for a service, assigning one on first use.

type LineWriter added in v0.56.0

type LineWriter struct {
	// contains filtered or unexported fields
}

LineWriter wraps a destination writer and, on each complete '\n'-terminated line, prepends a "[service] " prefix (colored when color==true), applies secret redaction, and writes the result. Partial lines are buffered until the next newline. Safe for concurrent Writes from multiple goroutines.

func NewLineWriter added in v0.56.0

func NewLineWriter(dst io.Writer, service string, color bool, redactor *SecretRedactor) *LineWriter

NewLineWriter builds a LineWriter for a service. color toggles ANSI coloring (callers pass ColorEnabled()). redactor may be nil.

func (*LineWriter) Write added in v0.56.0

func (w *LineWriter) Write(p []byte) (int, error)

type LogLine

type LogLine struct {
	Timestamp time.Time `json:"timestamp"`
	Service   string    `json:"service"`
	Message   string    `json:"message"`
	Type      string    `json:"type"` // "container" (live) or "service" (file-backed)
}

type Model

type Model struct {
	// contains filtered or unexported fields
}

func InitialModel

func InitialModel(rt provider.ContainerRuntime) Model

func InitialModelWithRedactor added in v0.25.0

func InitialModelWithRedactor(r *SecretRedactor, rt provider.ContainerRuntime) Model

InitialModelWithRedactor creates the TUI model with secret redaction enabled. All log lines will be scrubbed for known secret values before display.

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Model) View

func (m Model) View() string

type SecretRedactor added in v0.25.0

type SecretRedactor struct {
	// contains filtered or unexported fields
}

SecretRedactor replaces known secret values in log output with a redaction marker. Because devx centrally loads all secrets via vault/env integration, it can perform exact-match replacement rather than relying on pattern-based heuristics.

func NewSecretRedactor added in v0.25.0

func NewSecretRedactor() *SecretRedactor

NewSecretRedactor builds a redactor from the current environment. It collects all env-var values and filters out obviously non-sensitive short values (length <= 3) and common system paths to avoid false positives.

func NewSecretRedactorFromPairs added in v0.25.0

func NewSecretRedactorFromPairs(pairs []string) *SecretRedactor

NewSecretRedactorFromPairs builds a redactor from explicit KEY=VALUE pairs. Useful for testing or when secrets come from a vault loader rather than the process environment.

func (*SecretRedactor) Redact added in v0.25.0

func (r *SecretRedactor) Redact(s string) string

Redact replaces all known secret values in the input string.

type SinkMode added in v0.56.0

type SinkMode int

SinkMode mirrors orchestrator.LogMode without importing it (logs must not depend on orchestrator). The orchestrator maps its LogMode to these.

const (
	LogOffMode      SinkMode = iota // file only (no inline)
	LogRawMode                      // inline raw + file
	LogPrefixedMode                 // inline prefixed+colored + file
)

type Streamer

type Streamer struct {
	Lines    chan LogLine
	Errors   chan error
	Redactor *SecretRedactor
	Runtime  provider.ContainerRuntime
	// contains filtered or unexported fields
}

func NewStreamer

func NewStreamer(rt provider.ContainerRuntime) *Streamer

func (*Streamer) Start

func (s *Streamer) Start(ctx context.Context)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL