Documentation ¶
Index ¶
- type File
- type Tailer
- func (t *Tailer) DidRotate() (bool, error)
- func (t *Tailer) GetDetectedPattern() *regexp.Regexp
- func (t *Tailer) GetId() string
- func (t *Tailer) GetInfo() *status.InfoRegistry
- func (t *Tailer) GetType() string
- func (t *Tailer) Identifier() string
- func (t *Tailer) IsFinished() bool
- func (t *Tailer) NewRotatedTailer(file *File, outputChan chan *message.Message, ...) *Tailer
- func (t *Tailer) ReplaceSource(newSource *sources.LogSource)
- func (t *Tailer) Source() *sources.LogSource
- func (t *Tailer) Start(offset int64, whence int) error
- func (t *Tailer) StartFromBeginning() error
- func (t *Tailer) Stop()
- func (t *Tailer) StopAfterFileRotation()
- type TailerOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct { // Path contains the path to the file which should be tailed. Path string // IsWildcardPath is set to true when the File has been discovered // in a directory with wildcard(s) in the configuration. IsWildcardPath bool // Source is the ReplaceableSource that led to this File. Source *sources.ReplaceableSource }
File represents a file to tail
func (*File) GetScanKey ¶
GetScanKey returns a key used by the scanner to index the scanned file. The string uniquely identifies this File, even if sources for multiple containers use the same Path.
type Tailer ¶
type Tailer struct { PipelineMonitor metrics.PipelineMonitor // contains filtered or unexported fields }
Tailer tails a file, decodes the messages it contains, and passes them to a supplied output channel for further processing.
Operational Overview ¶
Tailers have three components, organized as a pipeline. The first, readForever, polls the file, trying to read more data. That data is passed to the second component, the decoder. The decoder produces decoder.Messages, which are passed to the third component, forwardMessages. This component translates the decoder.Messages into message.Messages and sends them to the tailer's output channel.
func NewTailer ¶
func NewTailer(opts *TailerOptions) *Tailer
NewTailer returns an initialized Tailer, read to be started.
The resulting Tailer will read from the given `file`, decode the content with the given `decoder`, and send the resulting log messages to outputChan. The Tailer takes ownership of the decoder and will start and stop it as necessary.
The Tailer must poll for content in the file. The `sleepDuration` parameter specifies how long the tailer should wait between polls.
func (*Tailer) DidRotate ¶
DidRotate returns true if the file has been log-rotated.
On *nix, when a log rotation occurs, the file can be either: - renamed and recreated - removed and recreated - truncated
func (*Tailer) GetDetectedPattern ¶
GetDetectedPattern returns the decoder's detected pattern.
func (*Tailer) GetInfo ¶
func (t *Tailer) GetInfo() *status.InfoRegistry
func (*Tailer) Identifier ¶
Identifier returns a string that identifies this tailer in the registry.
func (*Tailer) IsFinished ¶
IsFinished returns true if the tailer has flushed all messages to the output channel, either because it has been stopped or because of an error reading from the input file.
func (*Tailer) NewRotatedTailer ¶
func (t *Tailer) NewRotatedTailer(file *File, outputChan chan *message.Message, pipelineMonitor metrics.PipelineMonitor, decoder *decoder.Decoder, info *status.InfoRegistry, tagAdder tag.EntityTagAdder) *Tailer
NewRotatedTailer creates a new tailer that replaces this one, writing messages to a new channel and using an updated file and decoder.
func (*Tailer) ReplaceSource ¶
ReplaceSource replaces the current source
func (*Tailer) StartFromBeginning ¶
StartFromBeginning is a shortcut to start the tailer at the beginning of the file.
func (*Tailer) Stop ¶
func (t *Tailer) Stop()
Stop stops the tailer and returns only after all in-flight messages have been flushed to the output channel.
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
type TailerOptions ¶
type TailerOptions struct { OutputChan chan *message.Message // Required File *File // Required SleepDuration time.Duration // Required Decoder *decoder.Decoder // Required Info *status.InfoRegistry // Required Rotated bool // Optional TagAdder tag.EntityTagAdder // Required PipelineMonitor metrics.PipelineMonitor // Required }
TailerOptions holds all possible parameters that NewTailer requires in addition to optional parameters that can be optionally passed into. This can be used for more optional parameters if required in future