// TestGetLogger tests the GetLogger function package gologger import "testing" func TestGetLogger(t *testing.T) { // Initialize loggerMap and loggerConfig dl := GetLogger("default") if dl != defaultLogger { t.Errorf("GetLogger(\"defult\") should return defaultLogger") } dl.Error("test") Configure(LoggersConfig{ Appenders: map[string]LogAppenderConfig{ "console": { Type: "console", Formatter: "json", Options: map[string]interface{}{}, }, }, Categories: map[string]LogConfig{ "default": { Level: "info", Appenders: []string{"console"}, }, "app": { Level: "debug", Appenders: []string{"console"}, }, }, }) dl.Info("test") if dl.level != Info { t.Errorf("GetLogger(\"default\") should return defaultLogger") } al := GetLogger("app") if al == dl { t.Errorf("GetLogger(\"app\") should return a new logger") } al2 := GetLogger("app") if al2 != al { t.Errorf("GetLogger(\"app\") should return the same logger") } }