Pass log types to logger on creation

graph-rework
noah metz 2023-06-18 18:50:34 -06:00
parent 1d2047eee2
commit 52f77cc186
1 changed files with 3 additions and 3 deletions

@ -20,10 +20,10 @@ type DefaultLogger struct {
init bool
init_lock sync.Mutex
loggers map[string]zerolog.Logger
components []string
}
var log DefaultLogger = DefaultLogger{loggers: map[string]zerolog.Logger{}}
var all_components = []string{"update", "graph", "event", "resource", "manager", "test", "gql", "vex", "gqlws", "gqlws_new", "gqlws_hb", "listeners"}
var log DefaultLogger = DefaultLogger{loggers: map[string]zerolog.Logger{}, components: []string{"update", "graph", "event", "resource", "manager", "test", "gql", "gqlws", "gqlws_new", "gqlws_hb", "listeners"}}
func (logger * DefaultLogger) Init(components []string) error {
logger.init_lock.Lock()
@ -50,7 +50,7 @@ func (logger * DefaultLogger) Init(components []string) error {
}
writer := io.MultiWriter(file, os.Stdout)
for _, c := range(all_components) {
for _, c := range(logger.components) {
if component_enabled(c) == true {
logger.loggers[c] = zerolog.New(writer).With().Timestamp().Str("component", c).Logger()
}