file

package
v3.0.0-rc16+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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
	// contains filtered or unexported fields
}

File contains the state for a tailed file.

func New

func New(fs afero.Fs, pathname string, lines chan<- *logline.LogLine, seenBefore, seekToStart bool) (*File, error)

New returns a new File named by the given pathname. seenBefore indicates thta mtail believes it's seen this pathname nbefore, and seekToStart indicates that the file should be tailed from offset 0, not EOF.

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)

Jump to

Keyboard shortcuts

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