Documentation
¶
Index ¶
- Variables
- func OpenFile(name string) (file *os.File, err error)
- type Config
- type Line
- type SeekInfo
- type Tail
- func (tail *Tail) Cleanup()
- func (tail *Tail) CloseFile()
- func (tail *Tail) IsFileClosed() bool
- func (tail *Tail) Reopen(resetOffset bool) error
- func (tail *Tail) Stop() error
- func (tail *Tail) StopAtEOF()
- func (tail *Tail) Tell() (offset int64, err error)
- func (tail *Tail) UnexpectedError() (err error)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
Types ¶
type Config ¶
type Config struct {
// File-specifc
Location *SeekInfo // Seek to this location before tailing
ReOpen bool // Reopen recreated files (tail -F)
MustExist bool // Fail early if the file does not exist
Poll bool // Poll for file changes instead of using inotify
Pipe bool // Is a named pipe (mkfifo)
RateLimiter limiter
// Generic IO
Follow bool // Continue looking for new lines (tail -f)
MaxLineSize int // If non-zero, split longer lines into multiple lines
Logger telegraf.Logger
// Special handling for utf16
IsUTF16 bool
}
Config is used to specify how a file must be tailed.
type Line ¶
type Tail ¶
type Tail struct {
Filename string
Lines chan *Line
Config
tomb.Tomb // provides: Done, Kill, Dying
FileDeletedCh chan bool
// contains filtered or unexported fields
}
func TailFile ¶
TailFile begins tailing the file. Output stream is made available via the `Tail.Lines` channel. To handle errors during tailing, invoke the `Wait` or `Err` method after finishing reading from the `Lines` channel.
func (*Tail) Cleanup ¶
func (tail *Tail) Cleanup()
Cleanup removes inotify watches added by the tail package. This function is meant to be invoked from a process's exit handler. Linux kernel may not automatically remove inotify watches after the process exits.
func (*Tail) IsFileClosed ¶ added in v1.300054.0
func (*Tail) StopAtEOF ¶
func (tail *Tail) StopAtEOF()
StopAtEOF stops tailing as soon as the end of the file is reached. Does not wait until tailer is dead.
func (*Tail) Tell ¶
Return the file's current position, like stdio's ftell(). But this value is not very accurate. it may readed one line in the chan(tail.Lines), so it may lost one line.
func (*Tail) UnexpectedError ¶
A wrapper of tomb Err()