Beispiel #1
0
func main() {
	file := os.Args[1]

	logger := nlog.NewLogger(&nlog.Config{
		Level: nlog.Trace,
		Flag:  nlog.LstdFlags,
	})
	e := emitter{}

	plugin := in_tail.New(in_tail.Config{
		File:    file,
		Emitter: &e,
		Logger:  logger,
	})

	go waitSignal(plugin)

	if err := plugin.Start(); err != nil {
		fmt.Println(err)
	}
}
Beispiel #2
0
func run() error {
	output = out_fluent.New(out_fluent.Config{
		Config: fluent.Config{
			FluentPort:  Options.FluentPort,
			FluentHost:  Options.FluentHost,
			Timeout:     time.Millisecond * time.Duration(Options.Timeout),
			BufferLimit: Options.BufferLimit,
			RetryWait:   Options.RetryWait,
			MaxRetry:    Options.MaxRetry,
		},
		Tag:       Options.Tag,
		FieldName: Options.FieldName,
		Logger:    logger,
	})

	if err := output.Start(); err != nil {
		return err
	}

	inputs = make([]gigo.Input, len(Options.Files))

	for i, file := range Options.Files {
		input := in_tail.New(in_tail.Config{
			File:    file,
			Emitter: output,
			Logger:  logger,
		})

		if err := input.Start(); err != nil {
			return err
		}

		inputs[i] = input
	}

	wait()

	return nil
}