-
Notifications
You must be signed in to change notification settings - Fork 2
/
log_level_setting.go
46 lines (40 loc) · 1.12 KB
/
log_level_setting.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
package log4g
import "github.com/dspasibenko/log4g/collections"
type logLevelSetting struct {
loggerName string
level Level
}
/**
* Stores level setting for the provided loggerName
* Params:
* loggerName - should be eligable normalized logger name
*/
func setLogLevel(level Level, loggerName string, logLevels *collections.SortedSlice) *logLevelSetting {
if level < 0 {
return nil
}
var lls *logLevelSetting = &logLevelSetting{loggerName, level}
idx, found := logLevels.Find(lls)
if found {
lls = logLevels.At(idx).(*logLevelSetting)
lls.level = level
} else {
logLevels.Add(lls)
}
return lls
}
func getLogLevelSetting(loggerName string, logLevels *collections.SortedSlice) *logLevelSetting {
lProvider := getNearestAncestor(&logLevelSetting{loggerName: loggerName}, logLevels)
if lProvider == nil {
return nil
}
return lProvider.(*logLevelSetting)
}
// logNameProvider implementation
func (lls *logLevelSetting) name() string {
return lls.loggerName
}
// Comparator implementation
func (lls *logLevelSetting) Compare(other collections.Comparator) int {
return compare(lls, other.(*logLevelSetting))
}