mirror of
https://github.com/aykhans/sarin.git
synced 2026-10-16 14:43:53 +00:00
fix(logging): match log levels case-sensitively
This commit is contained in:
1 file changed
+4
-3
@@ -34,13 +34,14 @@ type runtimeLog struct {
|
|||||||
|
|
||||||
type runtimeLogger func(level runtimeLogLevel, text string)
|
type runtimeLogger func(level runtimeLogLevel, text string)
|
||||||
|
|
||||||
// SplitLogLevels parses a comma-separated log-level string into a normalized,
|
// SplitLogLevels parses a comma-separated log-level string into a deduplicated
|
||||||
// deduplicated slice of level tokens (lowercased and trimmed, empties dropped).
|
// slice of level tokens (surrounding whitespace trimmed, empties dropped). Level
|
||||||
|
// names are matched case-sensitively, like the other enum options.
|
||||||
func SplitLogLevels(levels string) []string {
|
func SplitLogLevels(levels string) []string {
|
||||||
var out []string
|
var out []string
|
||||||
seen := make(map[string]bool)
|
seen := make(map[string]bool)
|
||||||
for part := range strings.SplitSeq(levels, ",") {
|
for part := range strings.SplitSeq(levels, ",") {
|
||||||
token := strings.ToLower(strings.TrimSpace(part))
|
token := strings.TrimSpace(part)
|
||||||
if token == "" || seen[token] {
|
if token == "" || seen[token] {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user