@@ -15,10 +15,11 @@ import (
15
15
)
16
16
17
17
const (
18
- matchFirst = "first"
19
- matchLast = "last"
20
- matchNonFirst = "nonfirst"
21
- matchNonLast = "nonlast"
18
+ matchFirst = "first"
19
+ matchLast = "last"
20
+ matchNonFirst = "nonfirst"
21
+ matchNonLast = "nonlast"
22
+ defaultFlushAfter = 500 * time .Millisecond
22
23
)
23
24
24
25
func init () {
@@ -89,7 +90,7 @@ func NewMultilineAdapter(route *router.Route) (a router.LogAdapter, err error) {
89
90
return nil , errors .New ("multiline: invalid value for MULTILINE_MATCH (must be one of first|last|nonfirst|nonlast): " + matchType )
90
91
}
91
92
92
- flushAfter := 500 * time . Millisecond
93
+ flushAfter := defaultFlushAfter
93
94
flushAfterStr := os .Getenv ("MULTILINE_FLUSH_AFTER" )
94
95
if flushAfterStr != "" {
95
96
timeoutMS , errConv := strconv .Atoi (flushAfterStr )
@@ -100,7 +101,7 @@ func NewMultilineAdapter(route *router.Route) (a router.LogAdapter, err error) {
100
101
}
101
102
102
103
parts := strings .SplitN (route .Adapter , "+" , 2 )
103
- if len (parts ) != 2 {
104
+ if len (parts ) != 2 { //nolint:gomnd
104
105
return nil , errors .New ("multiline: adapter must have a sub-adapter, eg: multiline+raw+tcp" )
105
106
}
106
107
@@ -117,7 +118,7 @@ func NewMultilineAdapter(route *router.Route) (a router.LogAdapter, err error) {
117
118
route .Adapter = originalAdapter
118
119
119
120
out := make (chan * router.Message )
120
- checkInterval := flushAfter / 2
121
+ checkInterval := flushAfter / 2 //nolint:gomnd
121
122
122
123
return & Adapter {
123
124
out : out ,
@@ -135,7 +136,7 @@ func NewMultilineAdapter(route *router.Route) (a router.LogAdapter, err error) {
135
136
}
136
137
137
138
// Stream sends log data to the next adapter
138
- func (a * Adapter ) Stream (logstream chan * router.Message ) { //nolint:gocyclo
139
+ func (a * Adapter ) Stream (logstream chan * router.Message ) { //nolint:gocyclo,gocognit
139
140
wg := sync.WaitGroup {}
140
141
wg .Add (1 )
141
142
go func () {
@@ -165,7 +166,7 @@ func (a *Adapter) Stream(logstream chan *router.Message) { //nolint:gocyclo
165
166
166
167
cID := message .Container .ID
167
168
old , oldExists := a .buffers [cID ]
168
- if a .isFirstLine (message ) {
169
+ if a .isFirstLine (message ) { //nolint:nestif
169
170
if oldExists {
170
171
a .out <- old
171
172
}
0 commit comments