watch

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package watch 监听文件变动,并通知相应的日志收集器。

如果在收集日志过程中,文件被移动,因为fsnotify是基于文件名来识别文件的,就监听不到该文件的写变动。 既然fsnotify做不到文件移动后继续监听, 所以我们就只监听文件所在的目录,来获取文件的写入和创建事件。 在我们检测到文件移动后,我们将收集器映射到新的文件名。 我们只关心3种变动事件:

  1. Write 通知收集器文件有写入,应该进行日志收集。
  2. Create a. 文件被重命名:对比当前文件和所有已经打开的文件,如果是同一文件,更新收集器Map。 b. 目标文件被创建: 创建收集器收集该文件。
  3. Remove 文件被删除,关闭收集器

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Watch

func Watch(collectorMakers map[string]func() []Collector)

Types

type Collector

type Collector interface {
	NotifyWrite()
	NotifyClose()
	OpenedSameFile(os.FileInfo) bool
	Printf(format string, v ...interface{})
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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