file

package
v0.9.14 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLineEndSplitFunc

func NewLineEndSplitFunc(re *regexp.Regexp) bufio.SplitFunc

NewLineEndSplitFunc creates a bufio.SplitFunc that splits an incoming stream into tokens that end with a match to the regex pattern provided

func NewLineStartSplitFunc

func NewLineStartSplitFunc(re *regexp.Regexp) bufio.SplitFunc

NewLineStartSplitFunc creates a bufio.SplitFunc that splits an incoming stream into tokens that start with a match to the regex pattern provided

func NewNewlineSplitFunc

func NewNewlineSplitFunc(encoding encoding.Encoding) (bufio.SplitFunc, error)

NewNewlineSplitFunc splits log lines by newline, just as bufio.ScanLines, but never returning an token using EOF as a terminator

func ReadToEnd

func ReadToEnd(
	ctx context.Context,
	path string,
	startOffset int64,
	lastSeenFileSize int64,
	messenger fileUpdateMessenger,
	splitFunc bufio.SplitFunc,
	filePathField entry.Field,
	fileNameField entry.Field,
	inputOperator helper.InputOperator,
	maxLogSize int,
	encoding encoding.Encoding,
) error

ReadToEnd will read entries from a file and send them to the outputs of an input operator

Types

type InputConfig

type InputConfig struct {
	helper.InputConfig `yaml:",inline"`

	Include []string `json:"include,omitempty" yaml:"include,omitempty"`
	Exclude []string `json:"exclude,omitempty" yaml:"exclude,omitempty"`

	PollInterval    operator.Duration `json:"poll_interval,omitempty"     yaml:"poll_interval,omitempty"`
	Multiline       *MultilineConfig  `json:"multiline,omitempty"         yaml:"multiline,omitempty"`
	IncludeFileName bool              `json:"include_file_name,omitempty" yaml:"include_file_name,omitempty"`
	IncludeFilePath bool              `json:"include_file_path,omitempty" yaml:"include_file_path,omitempty"`
	StartAt         string            `json:"start_at,omitempty"          yaml:"start_at,omitempty"`
	MaxLogSize      int               `json:"max_log_size,omitempty"      yaml:"max_log_size,omitempty"`
	Encoding        string            `json:"encoding,omitempty"          yaml:"encoding,omitempty"`
}

InputConfig is the configuration of a file input operator

func NewInputConfig

func NewInputConfig(operatorID string) *InputConfig

func (InputConfig) Build

Build will build a file input operator from the supplied configuration

type InputOperator

type InputOperator struct {
	helper.InputOperator

	Include       []string
	Exclude       []string
	FilePathField entry.Field
	FileNameField entry.Field
	PollInterval  time.Duration
	SplitFunc     bufio.SplitFunc
	MaxLogSize    int
	// contains filtered or unexported fields
}

InputOperator is an operator that monitors files for entries

func (*InputOperator) Start

func (f *InputOperator) Start() error

Start will start the file monitoring process

func (*InputOperator) Stop

func (f *InputOperator) Stop() error

Stop will stop the file monitoring process

type MultilineConfig

type MultilineConfig struct {
	LineStartPattern string `json:"line_start_pattern" yaml:"line_start_pattern"`
	LineEndPattern   string `json:"line_end_pattern"   yaml:"line_end_pattern"`
}

MultilineConfig is the configuration a multiline operation

type PositionalScanner

type PositionalScanner struct {
	*bufio.Scanner
	// contains filtered or unexported fields
}

func NewPositionalScanner

func NewPositionalScanner(r io.Reader, maxLogSize int, startOffset int64, splitFunc bufio.SplitFunc) *PositionalScanner

func (*PositionalScanner) Pos

func (ps *PositionalScanner) Pos() int64

Jump to

Keyboard shortcuts

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