loglineparser

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NodeTypeText      = "text"
	NodeTypeAnsi      = "ansi"
	NodeTypeJSON      = "json"
	NodeTypeString    = "string"
	NodeTypeUUID      = "uuid"
	NodeTypeTimestamp = "timestamp"
	NodeTypeURL       = "url"
	NodeTypeNumber    = "number"
)

Node type constants

Variables

This section is empty.

Functions

This section is empty.

Types

type LogSpan

type LogSpan struct {
	Text      string   `json:"text"`
	ClassName []string `json:"classname,omitempty"`
}

LogSpan represents a segment of parsed log text with styling information

func ParseLine

func ParseLine(line string) []LogSpan

ParseLine parses a line with ANSI escape sequences and returns LogSpan segments

type Node added in v0.9.0

type Node struct {
	Type    string `json:"type"`
	Content string `json:"content"`
	Label   string `json:"label,omitempty"`
	Prev    *Node  `json:"-"`
	Next    *Node  `json:"-"`
}

Node represents a fundamental unit of parsed log data in a doubly linked list

func ProcessLine added in v0.9.0

func ProcessLine(line string) *Node

func (*Node) All added in v0.9.0

func (n *Node) All() iter.Seq[*Node]

All returns an iterator that yields all nodes starting from this node

func (*Node) IsAnsiType added in v0.9.0

func (n *Node) IsAnsiType() bool

IsAnsiType returns true if the node is an ANSI type

func (*Node) IsStructuredType added in v0.9.0

func (n *Node) IsStructuredType() bool

IsStructuredType returns true if the node is a structured type (JSON, string, UUID, etc.)

func (*Node) IsTextType added in v0.9.0

func (n *Node) IsTextType() bool

IsTextType returns true if the node is a text type

func (*Node) SetLabel added in v0.9.0

func (n *Node) SetLabel(label string)

SetLabel sets the label for a node

func (*Node) Splice added in v0.9.0

func (n *Node) Splice(newNodes []*Node) (*Node, *Node)

Splice replaces the current node with a slice of new nodes and returns (head, next)

type Position added in v0.9.0

type Position struct {
	Start int
	End   int
}

Position represents the start and end positions of content in a string

func FindFirstAnsiEscape added in v0.9.0

func FindFirstAnsiEscape(s string) *Position

FindFirstAnsiEscape finds the first ANSI escape sequence in the given string Returns nil if no ANSI escape is found, otherwise returns the position range

func FindFirstJSON added in v0.9.0

func FindFirstJSON(s string, allowArrays bool) *Position

FindFirstJSON finds the first valid JSON object or array in the given string Returns nil if no valid JSON is found, otherwise returns the position range

func FindFirstURL added in v0.9.0

func FindFirstURL(s string) *Position

FindFirstURL finds the first HTTP/HTTPS URL in the given string Returns nil if no URL is found, otherwise returns the position range Applies heuristics to avoid including trailing punctuation

func FindFirstUUID added in v0.9.0

func FindFirstUUID(s string) *Position

FindFirstUUID finds the first UUID in the given string Returns nil if no UUID is found, otherwise returns the position range

func IsJsonAt added in v0.9.0

func IsJsonAt(s string, index int) *Position

IsJsonAt checks if there is a valid JSON object or array starting at the given index Returns nil if no valid JSON is found, otherwise returns the position range

Jump to

Keyboard shortcuts

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