parse

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 10 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 parse implements docs/12 §5: log lines from a process's stdout and stderr become records (JSON lines, multiline text events, levels and exceptions). Used by logify run.

Index

Constants

View Source
const (
	IdleClose     = 500 * time.Millisecond
	MaxEventLines = 500
	MaxEventBytes = 40 * 1024
)

docs/12 §5: one parser per stream, each with its own open event. The clock is injected so tests replay pauses without sleeping. A StreamParser is not safe for concurrent use; logify run guards each one with a mutex.

View Source
const MaxLineBytes = 64 * 1024

docs/12 §5.1: lines end at \n (a trailing \r is removed), are cut to 64 KB and decoded as UTF-8 with replacement characters.

Variables

This section is empty.

Functions

func DetectLevel

func DetectLevel(line string) (int, bool)

DetectLevel applies §5.3 to an event's first line.

func LevelFromNumber

func LevelFromNumber(n float64) (int, bool)

LevelFromNumber reads the pino/bunyan scale; custom numbers map to the nearest lower standard level.

func LevelFromWord

func LevelFromWord(word string) (int, bool)

func ParseISOTime

func ParseISOTime(text string) (int64, bool)

ParseISOTime reads an ISO 8601 date and time; without an offset it is local time, as in JavaScript's Date.parse.

func StripANSI

func StripANSI(s string) string

Types

type Exception

type Exception struct {
	Type, Message, Stacktrace string
}

func ExtractException

func ExtractException(lines []string) (Exception, bool)

ExtractException applies §5.6.

type Line

type Line struct {
	Text      string
	Truncated bool
}

type LineSplitter

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

func (*LineSplitter) End

func (s *LineSplitter) End() []Line

func (*LineSplitter) Push

func (s *LineSplitter) Push(chunk []byte) []Line

type Parsed

type Parsed struct {
	Severity int
	Body     string
	Time     int64
	Attrs    []record.Attr
}

func ParseJSONLine

func ParseJSONLine(line string) (Parsed, bool)

ParseJSONLine returns the record of a line that is one JSON object.

type StreamParser

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

func NewStreamParser

func NewStreamParser(stream string, now func() time.Time, emit func(Parsed)) *StreamParser

func (*StreamParser) End

func (p *StreamParser) End()

func (*StreamParser) Push

func (p *StreamParser) Push(chunk []byte)

func (*StreamParser) Tick

func (p *StreamParser) Tick()

Tick closes the open event after IdleClose without a new line.

Jump to

Keyboard shortcuts

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