Skip to content

Commit 3d0abbd

Browse files
committed
fix(log): Fixing behavior of invert match for multi grep
Signed-off-by: Vincent Boutour <[email protected]>
1 parent aaf9802 commit 3d0abbd

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

pkg/log/log.go

+16-2
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,11 @@ func (l Logger) outputLog(reader io.Reader, outputter output.Outputter) {
228228
continue
229229
}
230230

231-
if match := l.matchRegexes(text); (match && l.invertRegexp) || (!l.invertRegexp && !match) {
231+
if l.invertRegexp {
232+
if !l.noneMatch(text) {
233+
continue
234+
}
235+
} else if !l.match(text) {
232236
continue
233237
}
234238

@@ -241,7 +245,17 @@ func (l Logger) outputLog(reader io.Reader, outputter output.Outputter) {
241245
}
242246
}
243247

244-
func (l Logger) matchRegexes(text string) bool {
248+
func (l Logger) noneMatch(text string) bool {
249+
for _, logRegexp := range l.logRegexes {
250+
if logRegexp.MatchString(text) {
251+
return false
252+
}
253+
}
254+
255+
return true
256+
}
257+
258+
func (l Logger) match(text string) bool {
245259
for _, logRegexp := range l.logRegexes {
246260
if !logRegexp.MatchString(text) {
247261
return false

0 commit comments

Comments
 (0)