blob: 8f7d2a91373d7a4c82da65bdf0e5f560f75cd7b6 (
plain) (
blame)
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
// vespa logfmt command
// Author: arnej
package logfmt
import (
"regexp"
)
// optional regular expression filter, as a CLI flag
type regexFlag struct {
regex *regexp.Regexp
}
func (re regexFlag) unmatched(s string) bool {
if re.regex == nil {
return false
}
return re.regex.FindStringIndex(s) == nil
}
func (v *regexFlag) Type() string {
return "regular expression"
}
func (v *regexFlag) String() string {
if v.regex == nil {
return "<none>"
}
return v.regex.String()
}
func (v *regexFlag) Set(val string) (r error) {
v.regex, r = regexp.Compile(val)
return
}
|