-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilter.go
More file actions
31 lines (26 loc) · 799 Bytes
/
filter.go
File metadata and controls
31 lines (26 loc) · 799 Bytes
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
package loggo
// Filter interface is used to check if the log
// should be written by then appender
type Filter interface {
ShouldLog(msg *Message) bool
}
// MinLogLevelFilter filters all messages
// with a log level strictly lower than MinLevel
type MinLogLevelFilter struct {
MinLevel Level
}
// ShouldLog returns true if msg.Level is greater or equal to
// the filter MinLevel
func (f *MinLogLevelFilter) ShouldLog(msg *Message) bool {
return msg.Level >= f.MinLevel
}
// MaxLogLevelFilter filters all messages
// with a log level strictly greater than MaxLevel
type MaxLogLevelFilter struct {
MaxLevel Level
}
// ShouldLog returns true if msg.Level is lower or equal to
// the filter MaxLevel
func (f *MaxLogLevelFilter) ShouldLog(msg *Message) bool {
return msg.Level <= f.MaxLevel
}