feat: enable filtering console output by severity level

This commit is contained in:
2024-06-04 13:02:29 +02:00
parent a2b61ea706
commit 225620da48
3 changed files with 28 additions and 10 deletions

View File

@ -1,6 +1,8 @@
package level
import (
"strings"
"git.ma-al.com/maal-libraries/observer/pkg/syslog"
"go.opentelemetry.io/otel/attribute"
)
@ -61,20 +63,21 @@ func (l SeverityLevel) String() string {
}
func FromString(level string) SeverityLevel {
level = strings.ToLower(level)
switch level {
case "ALERT":
case "alert":
return ALERT
case "CRIT":
case "crit", "critical":
return CRIT
case "ERR":
case "err", "error":
return ERR
case "WARN":
case "warn", "warning":
return WARN
case "INFO":
case "info":
return INFO
case "DEBUG":
case "debug":
return DEBUG
case "TRACE":
case "trace":
return TRACE
default:
return unset