forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
linereader.go
47 lines (38 loc) · 981 Bytes
/
linereader.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package harvester
import (
"golang.org/x/text/encoding"
"github.com/elastic/beats/filebeat/config"
"github.com/elastic/beats/filebeat/harvester/processor"
)
func createLineReader(
in FileSource,
codec encoding.Encoding,
bufferSize int,
maxBytes int,
readerConfig logFileReaderConfig,
jsonConfig *config.JSONConfig,
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 jsonConfig != nil {
p = processor.NewJSONProcessor(p, jsonConfig)
}
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
}