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 ¶
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.
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 ¶
DetectLevel applies §5.3 to an event's first line.
func LevelFromNumber ¶
LevelFromNumber reads the pino/bunyan scale; custom numbers map to the nearest lower standard level.
func LevelFromWord ¶
func ParseISOTime ¶
ParseISOTime reads an ISO 8601 date and time; without an offset it is local time, as in JavaScript's Date.parse.
Types ¶
type Exception ¶
type Exception struct {
Type, Message, Stacktrace string
}
func ExtractException ¶
ExtractException applies §5.6.
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 ¶
func ParseJSONLine ¶
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.