session

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package session provides session directory and symlink management.

Package session provides session directory and symlink management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanSessions added in v0.1.2

func CleanSessions(outputDir string, retain int, dryRun ...bool) ([]string, error)

CleanSessions removes old session directories from outputDir, keeping the newest retain count. Returns the list of deleted (or would-be-deleted) directory names. Only directories matching the timestamp pattern are considered sessions. The "latest" symlink is updated if it pointed to a deleted session. If dryRun is true, returns sessions that would be deleted without deleting them.

func FormatJSONL added in v0.1.3

func FormatJSONL(line docker.LogLine) []byte

FormatJSONL formats a LogLine as JSON Lines with auto-detection. If Content is a valid JSON object, metadata (ts, container, stream) is merged in. Otherwise, Content is wrapped in an envelope with a "message" field.

Types

type LogWriter

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

LogWriter writes logs to per-container files and a combined log file.

func NewLogWriter

func NewLogWriter(sessionDir string) (*LogWriter, error)

NewLogWriter creates a new log writer for a session.

func (*LogWriter) Close

func (w *LogWriter) Close() error

Close flushes and closes all files.

func (*LogWriter) Write

func (w *LogWriter) Write(line docker.LogLine)

Write queues a log line for writing. Silently drops if writer is closed.

type Metadata

type Metadata struct {
	StartTime  time.Time `json:"start_time"`
	Command    string    `json:"command"`
	Containers []string  `json:"containers"`
}

Metadata is written to metadata.json in the session directory.

type Session

type Session struct {
	Dir          string     // Full path to session directory (e.g., logs/2026-03-04-103001/)
	StartTime    time.Time  // Session start time
	Command      string     // Original command line
	Containers   []string   // Container names being logged
	ContainersMu sync.Mutex // Guards Containers slice for concurrent access
}

Session represents a logging session with metadata and output directory.

func NewSession

func NewSession(outputDir string, command string, containers []string) (*Session, error)

NewSession creates a new logging session with timestamped directory. Also creates/updates logs/latest symlink to point to this session.

Jump to

Keyboard shortcuts

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