Esempio n. 1
0
File: log.go Progetto: amundi/beats
func createLineReader(
	in FileSource,
	codec encoding.Encoding,
	bufferSize int,
	maxBytes int,
	readerConfig logFileReaderConfig,
	mlrConfig *config.MultilineConfig,
) (processor.LineProcessor, error) {
	var p processor.LineProcessor
	var err error

	fileReader, err := newLogFileReader(in, readerConfig)
	if err != nil {
		return nil, err
	}

	p, err = processor.NewLineSource(fileReader, codec, bufferSize)
	if err != nil {
		return nil, err
	}

	if mlrConfig != nil {
		p, err = processor.NewMultiline(p, maxBytes, mlrConfig)
		if err != nil {
			return nil, err
		}

		return processor.NewStripNewline(p), nil
	}

	p = processor.NewStripNewline(p)
	return processor.NewLimitProcessor(p, maxBytes), nil
}
Esempio n. 2
0
func (h *Harvester) newLineProcessor() (processor.LineProcessor, error) {

	readerConfig := h.newLogFileReaderConfig()

	var p processor.LineProcessor
	var err error

	fileReader, err := reader.NewLogFileReader(h.file, readerConfig, h.done)
	if err != nil {
		return nil, err
	}

	p, err = processor.NewLineEncoder(fileReader, h.encoding, h.config.BufferSize)
	if err != nil {
		return nil, err
	}

	if h.config.JSON != nil {
		p = processor.NewJSONProcessor(p, h.config.JSON)
	}

	p = processor.NewStripNewline(p)
	if h.config.Multiline != nil {
		p, err = processor.NewMultiline(p, "\n", h.config.MaxBytes, h.config.Multiline)
		if err != nil {
			return nil, err
		}
	}

	return processor.NewLimitProcessor(p, h.config.MaxBytes), nil
}
Esempio n. 3
0
File: log.go Progetto: yhyang1/beats
func createLineProcessor(
	in source.FileSource,
	codec encoding.Encoding,
	bufferSize int,
	maxBytes int,
	readerConfig reader.LogFileReaderConfig,
	jsonConfig *processor.JSONConfig,
	mlrConfig *processor.MultilineConfig,
	done chan struct{},
) (processor.LineProcessor, error) {
	var p processor.LineProcessor
	var err error

	fileReader, err := reader.NewLogFileReader(in, readerConfig, done)
	if err != nil {
		return nil, err
	}

	p, err = processor.NewLineEncoder(fileReader, codec, bufferSize)
	if err != nil {
		return nil, err
	}

	if jsonConfig != nil {
		p = processor.NewJSONProcessor(p, jsonConfig)
	}

	p = processor.NewStripNewline(p)
	if mlrConfig != nil {
		p, err = processor.NewMultiline(p, "\n", maxBytes, mlrConfig)
		if err != nil {
			return nil, err
		}
	}

	return processor.NewLimitProcessor(p, maxBytes), nil
}