logtailer

package module
v0.0.0-...-634328b Latest Latest
Warning

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

Go to latest
Published: May 9, 2018 License: MIT Imports: 11 Imported by: 0

README

logtailer

a common package for log tail

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefTimeLayout for parse WatchRule.StartAt/EndAt
	DefTimeLayout = "2006-01-02 15:04:05"
	// DefLogTimeLayout for parse log time
	DefLogTimeLayout = "2006/01/02 15:04:05"
	// DefTimeLocation which location used for time parse
	DefTimeLocation = time.Local

	// Debug show debug message
	Debug bool
	// DefDebugLogger print debug message
	DefDebugLogger = log.New(os.Stderr, "", log.Ldate|log.Lmicroseconds|log.Lshortfile)

	// DefHandFunc the default handler is be used when rule.handler empty
	DefHandFunc = func(rule *WatchRule, matchedIdx uint64, logTime time.Time, line string) {
		fmt.Printf("rule(%s) matched one: %d, %s, %s\n", rule.Path, matchedIdx, logTime.Format(rule.TimeLayout), line)
	}
)

Functions

This section is empty.

Types

type Handler

type Handler func(rule *WatchRule, matchedIdx uint64, logTime time.Time, line string)

Handler handle and process matched line

type WatchRule

type WatchRule struct {
	Path          string         `json:"path"` // can be dir/file path
	StartAtStr    string         `json:"start_at"`
	EndAtStr      string         `json:"end_at"`
	SeekEnd       bool           `json:"seek_end"` // is seek log file end when start process
	Match         string         `json:"match"`    // regexp
	WatchDirMs    int            `json:"watch_dir_ms"`
	LogTimeLayout string         `json:"log_time_layout"`
	TimeLayout    string         `json:"time_layout"`
	TimeLocation  *time.Location `json:"-"`
	Poll          bool           `json:"poll"`   // use poll instead inotify
	Follow        bool           `json:"follow"` // equal to tail -f

	Handler           Handler `json:"-"`
	HandlerWorkerNum  int     `json:"handler_worker_num"`
	HandlerWorkerPool *grpool.Pool
	// contains filtered or unexported fields
}

WatchRule log watch rule

func (*WatchRule) Close

func (rule *WatchRule) Close()

Close will block until closed

func (*WatchRule) Process

func (rule *WatchRule) Process() (err error)

Process start tail the rule.Path specific log file

func (*WatchRule) Wait

func (rule *WatchRule) Wait()

Wait wait for tailer end folloy=false

Jump to

Keyboard shortcuts

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