Add log.IsGreaterOrEqualTo, that take into consideration path-scoped log levels

This commit is contained in:
Deluan
2023-12-25 16:29:59 -05:00
parent 03119e5ccf
commit 51e07d4cb5
13 changed files with 60 additions and 19 deletions
+6
View File
@@ -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)