tail

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2019 License: MIT Imports: 15 Imported by: 0

README

tail code is copied-changed from telegraf tail

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearTailerOffset

func ClearTailerOffset(prefix string, tailer *tail.Tail)

ClearTailerOffset 删除tail文件对应的.offset文件

func GetFileIno

func GetFileIno(file string) (uint64, error)

GetFileIno 获得文件的Inode值。这样,在文件被重建时(文件名不变),可以使用Inode来确定文件是否被重新创建

func ReadTailFileOffset

func ReadTailFileOffset(prefix, file string, fallback *tail.SeekInfo) (*tail.SeekInfo, error)

ReadTailFileOffset 读取tail文件对应的.offset文件记录的偏移位置

func SaveTailerOffset

func SaveTailerOffset(prefix string, tailer *tail.Tail, lastOffset int64) (offset int64, changed bool)

SaveTailerOffset 保存tail文件读取的位置到对应的.offset文件

Types

type Liner

type Liner interface {
	ProcessLine(tailer *tail.Tail, line string, firstLine bool) error
}

Liner processes a line of tailer.

type Tail

type Tail struct {
	FromBeginning bool `pflag:"Read file from beginning"`
	Pipe          bool `pflag:"Whether file is a named pipe"`

	WatchMethod      string   `pflag:"Method used to watch for file updates(inotify/poll), default inotify"`
	OffsetSavePrefix string   `pflag:"Offset save file prefix in in ~, default logtail"`
	Files            []string `pflag:"Files to tail"`
	// contains filtered or unexported fields
}

Tail tail log files.

func NewTail

func NewTail(liner Liner) *Tail

NewTail create a new tail.

func (*Tail) Start

func (t *Tail) Start()

Start starts a tail go routine.

func (*Tail) Stop

func (t *Tail) Stop()

Stop stops the tail goroutine.

Jump to

Keyboard shortcuts

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