Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrStop = errors.New("tail should now stop")
)
Functions ¶
Types ¶
type Config ¶
type Config struct { // File-specifc Location *SeekInfo // Seek to this location before tailing ReOpen bool // Reopen recreated files (tail -F) ReOpenTruncated bool // Reopen truncated 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 *ratelimiter.LeakyBucket // Generic IO Follow bool // Continue looking for new lines (tail -f) MaxLineSize int // If non-zero, split longer lines into multiple lines // Logger, when nil, is set to tail.NewDefaultLogger() // To disable logging: set field to tail.DiscardingLogger Logger Logger }
Config is used to specify how a file must be tailed.
type Logger ¶ added in v1.2.0
type Logger interface { Fatal(v ...interface{}) Fatalf(format string, v ...interface{}) Fatalln(v ...interface{}) Panic(v ...interface{}) Panicf(format string, v ...interface{}) Panicln(v ...interface{}) Print(v ...interface{}) Printf(format string, v ...interface{}) Println(v ...interface{}) Debugf(format string, v ...interface{}) Debug(v ...interface{}) }
func NewDefaultLogger ¶ added in v1.2.0
func NewDefaultLogger() Logger
NewDefaultLogger creates new logger when Config.Logger == nil.
func NewDiscardingLogger ¶ added in v1.2.0
func NewDiscardingLogger() Logger
NewDiscardingLogger creates new disabled logger.
type Tail ¶
type Tail struct { Filename string Lines chan *Line Config tomb.Tomb // provides: Done, Kill, Dying // 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.
Click to show internal directories.
Click to hide internal directories.