tailer

package
v3.0.0-rc24+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package tailer provides a class that is responsible for tailing log files and extracting new log lines to be passed into the virtual machines.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OneShot

func OneShot(t *Tailer) error

OneShot puts the tailer in one-shot mode.

Types

type File

type File struct {
	Name     string    // Given name for the file (possibly relative, used for displau)
	Pathname string    // Full absolute path of the file used internally
	LastRead time.Time // time of the last read received on this handle
	// contains filtered or unexported fields
}

File provides an abstraction over files and named pipes being tailed by `mtail`.

func NewFile

func NewFile(pathname string, lines chan<- *logline.LogLine, seekToStart bool) (*File, error)

NewFile returns a new File named by the given pathname. `seenBefore` indicates that mtail believes it's seen this pathname before, indicating we should retry on error to open the file. `seekToStart` indicates that the file should be tailed from offset 0, not EOF; the latter is true for rotated files and for files opened when mtail is in oneshot mode.

func (*File) Close

func (f *File) Close() error

func (*File) Follow

func (f *File) Follow() error

Follow reads from the file until EOF. It tracks log rotations (i.e new inode or device).

func (*File) Read

func (f *File) Read() error

Read blocks of 4096 bytes from the File, sending LogLines to the given channel as newlines are encountered. If EOF is read, the partial line is stored to be concatenated to on the next call. At EOF, checks for truncation and resets the file offset if so.

func (*File) Stat

func (f *File) Stat() (os.FileInfo, error)

type Tailer

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

Tailer receives notification of changes from a Watcher and extracts new log lines from files. It also handles new log file creation events and log rotations.

func New

func New(lines chan<- *logline.LogLine, w watcher.Watcher, options ...func(*Tailer) error) (*Tailer, error)

New creates a new Tailer.

func (*Tailer) AddPattern

func (t *Tailer) AddPattern(pattern string) error

AddPattern adds a pattern to the list of patterns to filter filenames against.

func (*Tailer) Close

func (t *Tailer) Close() error

Close signals termination to the watcher.

func (*Tailer) Gc

func (t *Tailer) Gc() error

Gc removes file handles that have had no reads for 24h or more.

func (*Tailer) SetOption

func (t *Tailer) SetOption(options ...func(*Tailer) error) error

SetOption takes one or more option functions and applies them in order to Tailer.

func (*Tailer) StartGcLoop

func (t *Tailer) StartGcLoop(duration time.Duration)

StartExpiryLoop runs a permanent goroutine to expire metrics every duration.

func (*Tailer) TailPath

func (t *Tailer) TailPath(pathname string) error

TailPath registers a filesystem pathname to be tailed.

func (*Tailer) TailPattern

func (t *Tailer) TailPattern(pattern string) error

TailPattern registers a pattern to be tailed. If pattern is a plain file then it is watched for updates and opened. If pattern is a glob, then all paths that match the glob are opened and watched, and the directories containing those matches, if any, are watched.

func (*Tailer) WriteStatusHTML

func (t *Tailer) WriteStatusHTML(w io.Writer) error

WriteStatusHTML emits the Tailer's state in HTML format to the io.Writer w.

Jump to

Keyboard shortcuts

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