From 01cd32e70d8a6665b48e675f29f98a51b061ed3a Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Sun, 18 Jun 2023 18:54:06 -0600 Subject: [PATCH] Exported logger fields --- graph.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/graph.go b/graph.go index 177858b..aa8069e 100644 --- a/graph.go +++ b/graph.go @@ -19,11 +19,11 @@ type Logger interface { type DefaultLogger struct { init bool init_lock sync.Mutex - loggers map[string]zerolog.Logger - components []string + Loggers map[string]zerolog.Logger + Components []string } -var log DefaultLogger = DefaultLogger{loggers: map[string]zerolog.Logger{}, components: []string{"update", "graph", "event", "resource", "manager", "gql", "gqlws", "gqlws_new", "gqlws_hb", "listeners"}} +var log DefaultLogger = DefaultLogger{Loggers: map[string]zerolog.Logger{}, Components: []string{"update", "graph", "event", "resource", "manager", "gql", "gqlws", "gqlws_new", "gqlws_hb", "listeners"}} func (logger * DefaultLogger) Init(components []string) error { logger.init_lock.Lock() @@ -50,9 +50,9 @@ func (logger * DefaultLogger) Init(components []string) error { } writer := io.MultiWriter(file, os.Stdout) - for _, c := range(logger.components) { + for _, c := range(logger.Components) { if component_enabled(c) == true { - logger.loggers[c] = zerolog.New(writer).With().Timestamp().Str("component", c).Logger() + logger.Loggers[c] = zerolog.New(writer).With().Timestamp().Str("component", c).Logger() } } return nil @@ -60,7 +60,7 @@ func (logger * DefaultLogger) Init(components []string) error { func (logger * DefaultLogger) Logm(component string, fields map[string]interface{}, format string, items ... interface{}) { logger.Init([]string{"update"}) - l, exists := logger.loggers[component] + l, exists := logger.Loggers[component] if exists == true { log := l.Log() for key, value := range(fields) { @@ -72,7 +72,7 @@ func (logger * DefaultLogger) Logm(component string, fields map[string]interface func (logger * DefaultLogger) Logf(component string, format string, items ... interface{}) { logger.Init([]string{"update"}) - l, exists := logger.loggers[component] + l, exists := logger.Loggers[component] if exists == true { l.Log().Msg(fmt.Sprintf(format, items...)) }