logprogress

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package logprogress recognizes task progress and status text in a task's output lines. A progress pattern declares what its match means through its named capture groups (a Form); a status pattern captures free text.

It is a stdlib-only leaf shared by the template validator and the worker.

Index

Constants

View Source
const MaxStatusBytes = 200

MaxStatusBytes is the longest status text kept; longer text is cut on a UTF-8 boundary. The pattern-list limits are logpattern.MaxPatterns and logpattern.MaxPatternBytes.

Variables

This section is empty.

Functions

func CheckStatus

func CheckStatus(re *regexp.Regexp) error

CheckStatus rejects a status pattern carrying any named group other than status.

Types

type Form

type Form int

Form is the meaning of a progress pattern's named groups.

const (
	// FormPercent: group percent, 0 to 100.
	FormPercent Form = iota + 1
	// FormCounts: groups done and total.
	FormCounts
	// FormFrame: group frame, the frame now being worked on.
	FormFrame
	// FormFrameDone: group framedone, a frame just completed.
	FormFrameDone
	// FormFramePercent: group framepercent, completion of the current frame.
	FormFramePercent
	// FormFrameCounts: groups framedone and frametotal, within the current frame.
	FormFrameCounts
)

The six progress forms.

func ClassifyNames

func ClassifyNames(names []string) (Form, error)

ClassifyNames is ClassifyProgress from a pattern's group names alone, as regexp.Regexp.SubexpNames or regexp/syntax.Regexp.CapNames return them, so a caller that needs only the form need not build the program.

func ClassifyProgress

func ClassifyProgress(re *regexp.Regexp) (Form, error)

ClassifyProgress returns the Form a progress pattern's named groups declare. Unnamed groups are ignored.

func (Form) UsesFrames

func (f Form) UsesFrames() bool

UsesFrames reports whether the form is measured against the task's frames.

func (Form) WithinFrame

func (f Form) WithinFrame() bool

WithinFrame reports whether the form measures progress inside the current frame rather than naming a frame.

type Matcher

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

Matcher turns output lines into progress and status updates. It is safe for concurrent use.

func Compile

func Compile(progress, status []string, frames string, clean func(string) string) (*Matcher, error)

Compile builds a Matcher. frames is the task's frame-parameter value ("5", "1-10", "1-19:2", "1-3,7,8"); it must parse when any progress pattern uses frames and is ignored otherwise.

clean, which may be nil, cleans each status capture before the matcher tests it for empty and cuts it to MaxStatusBytes, so text it drops (leading space, control characters) neither uses up the limit nor stops a later status pattern from being tried. The worker passes its status-text sanitizer; it is a parameter so this package stays stdlib-only.

func (*Matcher) Observe

func (m *Matcher) Observe(line string) Update

Observe feeds one output line to the matcher.

type Update

type Update struct {
	Progress    int
	HasProgress bool
	Status      string
	HasStatus   bool
}

Update is what one output line told the matcher.

Jump to

Keyboard shortcuts

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