parser

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONParser

type JSONParser struct{}

JSONParser parses structured JSON logs

func NewJSONParser

func NewJSONParser() *JSONParser

NewJSONParser creates a new JSON parser

func (*JSONParser) Parse

func (p *JSONParser) Parse(source string, line string, timestamp time.Time) (*LogEntry, bool)

Parse attempts to parse a JSON log line

type LogEntry

type LogEntry struct {
	Timestamp  time.Time
	Level      LogLevel
	Source     string
	Message    string
	Raw        string
	IsError    bool
	Stacktrace string
	TraceID    string
}

LogEntry represents a parsed log entry

func ParseLine

func ParseLine(source string, line string) *LogEntry

ParseLine is a convenience function that creates a parser and parses a single line

type LogLevel

type LogLevel string

LogLevel represents the severity of a log entry

const (
	LevelDebug LogLevel = "debug"
	LevelInfo  LogLevel = "info"
	LevelWarn  LogLevel = "warn"
	LevelError LogLevel = "error"
)

type MultiParser

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

MultiParser manages multiple parsers and maintains state

func NewMultiParser

func NewMultiParser() *MultiParser

NewMultiParser creates a new multi-format parser

func (*MultiParser) Flush

func (m *MultiParser) Flush(source string) *LogEntry

Flush returns any in-progress multi-line entries

func (*MultiParser) ParseLine

func (m *MultiParser) ParseLine(source string, line string, timestamp time.Time) *LogEntry

ParseLine attempts to parse a log line using available parsers

type PlainTextParser

type PlainTextParser struct{}

PlainTextParser parses unstructured plain text logs

func NewPlainTextParser

func NewPlainTextParser() *PlainTextParser

NewPlainTextParser creates a new plain text parser

func (*PlainTextParser) Parse

func (p *PlainTextParser) Parse(source string, line string, timestamp time.Time) *LogEntry

Parse parses a plain text log line with heuristic level detection

type PythonParser

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

PythonParser detects and groups Python tracebacks

func NewPythonParser

func NewPythonParser() *PythonParser

NewPythonParser creates a new Python traceback parser

func (*PythonParser) Flush

func (p *PythonParser) Flush(source string) *LogEntry

Flush returns any in-progress traceback entry

func (*PythonParser) IsInProgress

func (p *PythonParser) IsInProgress() bool

IsInProgress returns true if we're currently parsing a multi-line traceback

func (*PythonParser) Parse

func (p *PythonParser) Parse(source string, line string, timestamp time.Time) (*LogEntry, bool)

Parse checks if this line starts a Python traceback

Jump to

Keyboard shortcuts

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