file

package
v0.0.0-...-3dd6856 Latest Latest
Warning

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

Go to latest
Published: May 20, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSleepDuration = 1 * time.Second

DefaultSleepDuration represents the amount of time the tailer waits before reading new data when no data is received

Variables

This section is empty.

Functions

func DidRotate

func DidRotate(file *os.File, lastReadOffset int64) (bool, error)

DidRotate returns true if the file has been log-rotated. When a log rotation occurs, the file can be either: - renamed and recreated - removed and recreated - truncated

func Position

func Position(registry auditor.Registry, identifier string, tailFromBeginning bool) (int64, int, error)

Position returns the position from where logs should be collected.

Types

type File

type File struct {
	Path           string
	IsWildcardPath bool
	Source         *config.LogSource
}

File represents a file to tail

func NewFile

func NewFile(path string, source *config.LogSource) *File

NewFile returns a new File

type Provider

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

Provider implements the logic to retrieve at most filesLimit Files defined in sources

func NewProvider

func NewProvider(filesLimit int) *Provider

NewProvider returns a new Provider

func (*Provider) CollectFiles

func (p *Provider) CollectFiles(source *config.LogSource) ([]*File, error)

CollectFiles returns all the files matching the source path.

func (*Provider) FilesToTail

func (p *Provider) FilesToTail(sources []*config.LogSource) []*File

FilesToTail returns all the Files matching paths in sources, it cannot return more than filesLimit Files. For now, there is no way to prioritize specific Files over others, they are just returned in reverse lexicographical order, see `searchFiles`

type Scanner

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

Scanner checks all files provided by fileProvider and create new tailers or update the old ones if needed

func NewScanner

func NewScanner(sources *config.LogSources, tailingLimit int, pipelineProvider pipeline.Provider, registry auditor.Registry, tailerSleepDuration time.Duration) *Scanner

NewScanner returns a new scanner.

func (*Scanner) Start

func (s *Scanner) Start()

Start starts the Scanner

func (*Scanner) Stop

func (s *Scanner) Stop()

Stop stops the Scanner and its tailers in parallel, this call returns only when all the tailers are stopped

type Tailer

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

Tailer tails one file and sends messages to an output channel

func NewTailer

func NewTailer(outputChan chan *message.Message, source *config.LogSource, path string, sleepDuration time.Duration, isWildcardPath bool) *Tailer

NewTailer returns an initialized Tailer

func (*Tailer) GetReadOffset

func (t *Tailer) GetReadOffset() int64

GetReadOffset returns the position of the last byte read in file

func (*Tailer) Identifier

func (t *Tailer) Identifier() string

Identifier returns a string that uniquely identifies a source

func (*Tailer) Start

func (t *Tailer) Start(offset int64, whence int) error

Start let's the tailer open a file and tail from whence

func (*Tailer) StartFromBeginning

func (t *Tailer) StartFromBeginning() error

StartFromBeginning lets the tailer start tailing its file from the beginning

func (*Tailer) Stop

func (t *Tailer) Stop()

Stop stops the tailer and returns only when the decoder is flushed

func (*Tailer) StopAfterFileRotation

func (t *Tailer) StopAfterFileRotation()

StopAfterFileRotation prepares the tailer to stop after a timeout to finish reading its file that has been log-rotated

Jump to

Keyboard shortcuts

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