Add log.IsGreaterOrEqualTo, that take into consideration path-scoped log levels
This commit is contained in:
@@ -106,6 +106,7 @@ func levelFromString(l string) Level {
|
||||
return level
|
||||
}
|
||||
|
||||
// SetLogLevels sets the log levels for specific paths in the codebase.
|
||||
func SetLogLevels(levels map[string]string) {
|
||||
for k, v := range levels {
|
||||
logLevels = append(logLevels, levelPath{path: k, level: levelFromString(v)})
|
||||
@@ -154,6 +155,11 @@ func CurrentLevel() Level {
|
||||
return currentLevel
|
||||
}
|
||||
|
||||
// IsGreaterOrEqualTo returns true if the caller's current log level is equal or greater than the provided level.
|
||||
func IsGreaterOrEqualTo(level Level) bool {
|
||||
return shouldLog(level)
|
||||
}
|
||||
|
||||
func Fatal(args ...interface{}) {
|
||||
log(LevelFatal, args...)
|
||||
os.Exit(1)
|
||||
|
||||
Reference in New Issue
Block a user