From ad456c3725cbdcd6a968a62fa9e6ee2f9ae8859f Mon Sep 17 00:00:00 2001 From: gremat <50012463+gremat@users.noreply.github.com> Date: Thu, 8 Jan 2026 17:51:06 +0100 Subject: [PATCH] feat: add log object type search that ignores case --- thorlog/v3/objectlist.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/thorlog/v3/objectlist.go b/thorlog/v3/objectlist.go index d41da04..80522a3 100644 --- a/thorlog/v3/objectlist.go +++ b/thorlog/v3/objectlist.go @@ -1,10 +1,26 @@ package thorlog -import "github.com/NextronSystems/jsonlog" +import ( + "strings" + + "github.com/NextronSystems/jsonlog" +) // LogObjectTypes is a map of all log object types. Each log object type must be registered using AddLogObjectType. var LogObjectTypes = map[string]jsonlog.Object{} +// FindLogObjectType looks up a log object type by name, ignoring case. It +// returns the correctly-folded name (with which the type can be found in +// LogObjectTypes) and true if found, or "" and false if not found. +func FindLogObjectType(name string) (string, bool) { + for registeredName := range LogObjectTypes { + if strings.EqualFold(registeredName, name) { + return registeredName, true + } + } + return "", false +} + // AddLogObjectType registers a new log object type. It panics if a log object type with the same name is already registered. func AddLogObjectType(name string, obj jsonlog.Object) { if _, ok := LogObjectTypes[name]; ok {