Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion thorlog/v3/objectlist.go
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down