@@ -15,10 +15,11 @@ import (
1515)
1616
1717const (
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
2223)
2324
2425func init () {
@@ -89,7 +90,7 @@ func NewMultilineAdapter(route *router.Route) (a router.LogAdapter, err error) {
8990 return nil , errors .New ("multiline: invalid value for MULTILINE_MATCH (must be one of first|last|nonfirst|nonlast): " + matchType )
9091 }
9192
92- flushAfter := 500 * time . Millisecond
93+ flushAfter := defaultFlushAfter
9394 flushAfterStr := os .Getenv ("MULTILINE_FLUSH_AFTER" )
9495 if flushAfterStr != "" {
9596 timeoutMS , errConv := strconv .Atoi (flushAfterStr )
@@ -100,7 +101,7 @@ func NewMultilineAdapter(route *router.Route) (a router.LogAdapter, err error) {
100101 }
101102
102103 parts := strings .SplitN (route .Adapter , "+" , 2 )
103- if len (parts ) != 2 {
104+ if len (parts ) != 2 { //nolint:gomnd
104105 return nil , errors .New ("multiline: adapter must have a sub-adapter, eg: multiline+raw+tcp" )
105106 }
106107
@@ -117,7 +118,7 @@ func NewMultilineAdapter(route *router.Route) (a router.LogAdapter, err error) {
117118 route .Adapter = originalAdapter
118119
119120 out := make (chan * router.Message )
120- checkInterval := flushAfter / 2
121+ checkInterval := flushAfter / 2 //nolint:gomnd
121122
122123 return & Adapter {
123124 out : out ,
@@ -135,7 +136,7 @@ func NewMultilineAdapter(route *router.Route) (a router.LogAdapter, err error) {
135136}
136137
137138// 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
139140 wg := sync.WaitGroup {}
140141 wg .Add (1 )
141142 go func () {
@@ -165,7 +166,7 @@ func (a *Adapter) Stream(logstream chan *router.Message) { //nolint:gocyclo
165166
166167 cID := message .Container .ID
167168 old , oldExists := a .buffers [cID ]
168- if a .isFirstLine (message ) {
169+ if a .isFirstLine (message ) { //nolint:nestif
169170 if oldExists {
170171 a .out <- old
171172 }
0 commit comments