Help us shape the future of Go! Take the 2026 Go Developer Survey

runlog

package
v1.60.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package runlog manages per-command session log files.

Verbose commands (git bulk syncs, system updates) produce far more output than fits a clean terminal summary. runlog captures the full log stream to a timestamped file under the OS cache dir while the terminal shows only the summary. Use `eng logs show` to inspect a past run.

File logging is skipped when ui.DisableProgress is set. That flag is only ever set by tests, so production runs always log while `go test` never touches the real cache directory.

Index

Constants

View Source
const KeepRuns = 20

KeepRuns is how many recent session logs are retained. Older files are pruned whenever a new session starts.

Variables

This section is empty.

Functions

func Dir

func Dir() (string, error)

Dir returns the session log directory, creating it if needed. ENG_LOG_DIR overrides the default (OS cache dir), which also keeps tests hermetic.

func Finish

func Finish(path string)

Finish prints the "full log" pointer line. It is a no-op for empty paths, so commands can `defer runlog.Finish(path)` unconditionally: the pointer always lands after the command summary.

func ParseName

func ParseName(name string) (string, time.Time)

ParseName splits a session log filename into its command slug and timestamp. Unknown shapes return the raw base name and the zero time.

func Start

func Start(command string) (string, func())

Start begins a file-logging session for the named command (e.g. "git-sync-all"). It returns the log file path and a stop function that must be deferred by the caller. When file logging is unavailable (tests, unwritable cache dir) it returns "" and a no-op stop.

Types

type Entry

type Entry struct {
	Name    string
	Path    string
	ModTime time.Time
	Size    int64
}

Entry describes one session log file.

func List

func List() ([]Entry, error)

List returns session log entries, newest first. Missing dir → empty list.

func Resolve

func Resolve(name string) (Entry, error)

Resolve finds a log by exact name, unique prefix, or "" for the latest.

Jump to

Keyboard shortcuts

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