46 lines
913 B
Go
46 lines
913 B
Go
// TestGetLogger tests the GetLogger function
|
|
package gologger
|
|
|
|
import "testing"
|
|
|
|
func TestGetLogger(t *testing.T) {
|
|
// Initialize loggerMap and loggerConfig
|
|
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 := GetLogger("default")
|
|
// if dl != defaultLogger {
|
|
// t.Errorf("GetLogger(\"defult\") should return defaultLogger")
|
|
// }
|
|
dl.Error("test")
|
|
|
|
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")
|
|
}
|
|
|
|
}
|