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 ¶
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 ¶
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 ¶
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 ¶
ClassifyProgress returns the Form a progress pattern's named groups declare. Unnamed groups are ignored.
func (Form) UsesFrames ¶
UsesFrames reports whether the form is measured against the task's frames.
func (Form) WithinFrame ¶
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 ¶
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.