-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter.go
55 lines (46 loc) · 1.36 KB
/
filter.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
48
49
50
51
52
53
54
55
package glog
// Filter used to control the export behavior in Exporter.
type Filter interface {
Match(level Level) bool
}
// MatchFunc is wrappers for match the specified level.
type MatchFunc func(level Level) bool
func (f MatchFunc) Match(level Level) bool {
return f(level)
}
// MatchGTLevel used to match an level is granter than the level(`lvl`).
func MatchGTLevel(lvl Level) Filter {
return MatchFunc(func(level Level) bool {
return level > lvl
})
}
// MatchGTELevel used to match an level is granter than or equal the specified level(`lvl`).
func MatchGTELevel(lvl Level) Filter {
return MatchFunc(func(level Level) bool {
return level >= lvl
})
}
// MatchLTLevel used to match an level is less than the level(`lvl`).
func MatchLTLevel(lvl Level) Filter {
return MatchFunc(func(level Level) bool {
return level < lvl
})
}
// MatchLTELevel used to match an level is less than or equal the level(`lvl`).
func MatchLTELevel(lvl Level) Filter {
return MatchFunc(func(level Level) bool {
return level <= lvl
})
}
// MatchEQLevel used to match an level is equal the level(`lvl`).
func MatchEQLevel(lvl Level) Filter {
return MatchFunc(func(level Level) bool {
return level == lvl
})
}
// MatchNELevel used to match an level is not equal the level(`lvl`).
func MatchNELevel(lvl Level) Filter {
return MatchFunc(func(level Level) bool {
return level != lvl
})
}