logparser

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package logparser parses logs.

Index

Constants

View Source
const ISO8601Millis = "2006-01-02T15:04:05.000Z0700"

ISO8601Millis time format with millisecond precision.

Variables

This section is empty.

Functions

func DeductNanos added in v0.7.0

func DeductNanos(n int64) (int64, bool)

DeductNanos returns unix nano from arbitrary time integer, deducting resolution by range.

Types

type GenericJSONParser

type GenericJSONParser struct{}

GenericJSONParser can parse generic json into Line.

func (GenericJSONParser) Detect

func (GenericJSONParser) Detect(line string) bool

Detect if line is parsable by this parser.

func (GenericJSONParser) Parse

func (GenericJSONParser) Parse(data []byte) (*Line, error)

Parse generic json into Line.

func (GenericJSONParser) String

func (GenericJSONParser) String() string

type Line

type Line struct {
	Timestamp      otelstorage.Timestamp `json:"timestamp"`
	TraceID        otelstorage.TraceID   `json:"trace_id"`
	SpanID         otelstorage.SpanID    `json:"span_id"`
	Attrs          otelstorage.Attrs     `json:"attrs"`
	SeverityNumber plog.SeverityNumber   `json:"severity_number"`
	SeverityText   string                `json:"severity_text"`
	Body           string                `json:"body"`
}

Line represents single parsed line that can be converted to [logstorage.Record].

func (Line) Encode

func (l Line) Encode(e *jx.Encoder)

Encode line as json.

func (Line) String

func (l Line) String() string

type LogFmtParser

type LogFmtParser struct{}

LogFmtParser parses logfmt lines.

func (LogFmtParser) Detect

func (LogFmtParser) Detect(line string) bool

Detect if line is parsable by this parser.

func (LogFmtParser) Parse

func (LogFmtParser) Parse(data []byte) (*Line, error)

Parse line.

func (LogFmtParser) String

func (LogFmtParser) String() string

type Parser

type Parser interface {
	// Parse parses data and returns a line.
	//
	// TODO: refactor to `Parse(data []byte, target *logstorage.Record) error`
	Parse(data []byte) (*Line, error)
	// Detect whether data is parsable.
	//
	// TODO: refactor to `Detect(data []byte) bool`
	Detect(line string) bool
	String() string
}

Parser parses logs.

type ZapDevelopmentParser added in v0.4.0

type ZapDevelopmentParser struct{}

ZapDevelopmentParser parses zap's development mode lines.

func (ZapDevelopmentParser) Detect added in v0.4.0

func (ZapDevelopmentParser) Detect(line string) bool

Detect if line is parsable by this parser.

func (ZapDevelopmentParser) Parse added in v0.4.0

func (ZapDevelopmentParser) Parse(data []byte) (*Line, error)

Parse line.

func (ZapDevelopmentParser) String added in v0.4.0

func (ZapDevelopmentParser) String() string

Jump to

Keyboard shortcuts

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