logjs

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHookTimeout = errors.New("logjs: js hook timeout")
View Source
var ErrNoRegister = errors.New("logjs: script did not call register()")

Functions

func ParseOptions

func ParseOptions(opts Options) (options, error)

Types

type ErrorRecord

type ErrorRecord struct {
	Module     string  `json:"module"`
	Tag        string  `json:"tag"`
	Hook       string  `json:"hook"`
	Source     string  `json:"source"`
	LineNumber int64   `json:"lineNumber"`
	Timeout    bool    `json:"timeout"`
	Message    string  `json:"message"`
	RawLine    *string `json:"rawLine,omitempty"`
}

type Event

type Event struct {
	Timestamp  *string        `json:"timestamp,omitempty"`
	Level      string         `json:"level"`
	Message    string         `json:"message"`
	Fields     map[string]any `json:"fields"`
	Tags       []string       `json:"tags"`
	Source     string         `json:"source"`
	Raw        string         `json:"raw"`
	LineNumber int64          `json:"lineNumber"`
}

type Fanout

type Fanout struct {
	Modules []*Module
}

Fanout runs multiple independent JS modules against the same input stream. Each emitted event is tagged with the module's tag/name.

func LoadFanoutFromFiles

func LoadFanoutFromFiles(ctx context.Context, scriptPaths []string, opts Options) (*Fanout, error)

func (*Fanout) Close

func (f *Fanout) Close(ctx context.Context) error

func (*Fanout) ProcessLine

func (f *Fanout) ProcessLine(ctx context.Context, line string, source string, lineNumber int64) ([]*Event, []*ErrorRecord, error)

type Module

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

func LoadFromFile

func LoadFromFile(ctx context.Context, scriptPath string, opts Options) (*Module, error)

func (*Module) Close

func (m *Module) Close(ctx context.Context) error

func (*Module) Info

func (m *Module) Info() ModuleInfo

func (*Module) Name

func (m *Module) Name() string

func (*Module) ProcessLine

func (m *Module) ProcessLine(ctx context.Context, line string, source string, lineNumber int64) ([]*Event, []*ErrorRecord, error)

func (*Module) ScriptPath

func (m *Module) ScriptPath() string

func (*Module) Stats

func (m *Module) Stats() Stats

func (*Module) Tag

func (m *Module) Tag() string

type ModuleInfo

type ModuleInfo struct {
	Name         string
	Tag          string
	HasParse     bool
	HasFilter    bool
	HasTransform bool
	HasInit      bool
	HasShutdown  bool
	HasOnError   bool
}

type Options

type Options struct {
	HookTimeout string
}

type Stats

type Stats struct {
	LinesProcessed int64
	EventsEmitted  int64
	LinesDropped   int64
	HookErrors     int64
	HookTimeouts   int64
}

Jump to

Keyboard shortcuts

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