devlogs

package
v0.0.0-...-3776344 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelDebug  = "DEBUG"
	LevelInfo   = "INFO"
	LevelWarn   = "WARN"
	LevelError  = "ERROR"
	LevelSystem = "SYSTEM"
)

Variables

This section is empty.

Functions

func CleanLogDir

func CleanLogDir(celerityDir string) error

CleanLogDir removes the log directory and its contents.

Types

type Formatter

type Formatter struct {
	UseColor bool
}

Formatter formats parsed log lines with optional ANSI colors.

func (*Formatter) Format

func (f *Formatter) Format(line LogLine) string

Format renders a LogLine as a human-readable string. Output includes timestamp, level, handler prefix, message, and any extra fields on indented lines below the message.

type LogFileWriter

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

LogFileWriter demultiplexes parsed log lines into per-handler files and a combined log file. All output is plain text (no ANSI).

func NewLogFileWriter

func NewLogFileWriter(celerityDir string) (*LogFileWriter, error)

NewLogFileWriter creates a LogFileWriter that writes to {celerityDir}/logs/. Opens all.log and infra.log in append mode. Handler files are opened lazily.

func (*LogFileWriter) Close

func (w *LogFileWriter) Close() error

Close closes all open file handles.

func (*LogFileWriter) HandlerFiles

func (w *LogFileWriter) HandlerFiles() []string

HandlerFiles returns the names of handler-specific log files that have been written.

func (*LogFileWriter) LogDir

func (w *LogFileWriter) LogDir() string

LogDir returns the path to the log directory.

func (*LogFileWriter) Write

func (w *LogFileWriter) Write(line LogLine) error

Write writes a parsed log line to all.log and the appropriate handler/infra file.

type LogLine

type LogLine struct {
	Timestamp   string
	Level       string
	Message     string
	HandlerName string
	RequestID   string
	// Source identifies the origin of the log line. "runtime" indicates a
	// Rust core runtime log (tracing JSON); empty for SDK/application logs.
	Source  string
	RawLine string
	Extra   map[string]any
}

LogLine is a parsed container log line with extracted metadata.

func (*LogLine) MatchesHandler

func (l *LogLine) MatchesHandler(filter string) bool

MatchesHandler checks if the handler name contains the filter substring.

func (*LogLine) MatchesLevel

func (l *LogLine) MatchesLevel(minLevel string) bool

MatchesLevel checks if the log line meets the minimum level threshold.

type LogParser

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

LogParser dispatches to runtime-specific SDK parsers and falls back to plain-text passthrough for unrecognised lines.

func NewLogParser

func NewLogParser(runtime string) *LogParser

NewLogParser creates a parser configured for the given application runtime.

func (*LogParser) Parse

func (p *LogParser) Parse(raw string) LogLine

Parse extracts structured metadata from a raw log line. Order: tracing JSON → SDK parser → plain-text passthrough.

type SDKLogParseFunc

type SDKLogParseFunc func(raw string) (LogLine, bool)

SDKLogParseFunc attempts to parse a raw log line in an SDK-specific format.

type StreamOptions

type StreamOptions struct {
	Follow        bool
	Tail          string
	Since         string
	HandlerFilter string
	LevelFilter   string
}

StreamOptions configures log streaming with filtering.

type Streamer

type Streamer struct {

	// FileWriter optionally tees parsed lines to per-handler log files.
	FileWriter *LogFileWriter
	// contains filtered or unexported fields
}

Streamer reads container logs from the Docker API, parses them, applies filters, and writes formatted output.

func NewStreamer

func NewStreamer(
	dockerMgr docker.RuntimeContainerManager,
	runtime string,
	useColor bool,
) *Streamer

NewStreamer creates a log streamer configured for the given application runtime.

func (*Streamer) Stream

func (s *Streamer) Stream(
	ctx context.Context,
	containerID string,
	opts StreamOptions,
	writer io.Writer,
) error

Stream reads and formats container logs to the given writer. Parses each line independently (JSON or plain-text passthrough). Blocks until context cancellation or stream end.

func (*Streamer) SyncToFiles

func (s *Streamer) SyncToFiles(
	ctx context.Context,
	containerID string,
	opts StreamOptions,
) (*SyncResult, error)

SyncToFiles reads all available container logs and writes them to log files without any stdout output. FileWriter must be set before calling.

type SyncResult

type SyncResult struct {
	LogDir       string
	TotalLines   int
	HandlerFiles []string
}

SyncResult summarises a SyncToFiles operation.

Jump to

Keyboard shortcuts

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