add map for logger
This commit is contained in:
parent
5b00614d99
commit
14ac4e7469
11
main.go
11
main.go
|
@ -14,6 +14,8 @@ const (
|
|||
Trace
|
||||
)
|
||||
|
||||
var loggerMap map[string]Logger
|
||||
|
||||
type LogConfig struct {
|
||||
Name string
|
||||
Level int
|
||||
|
@ -49,5 +51,12 @@ func (l *Logger) Trace(msg string) {
|
|||
l.log(Trace, msg)
|
||||
}
|
||||
func GetLogger(logConfig LogConfig) Logger {
|
||||
return Logger{logConfig}
|
||||
if logger, ok := loggerMap[logConfig.Name]; ok {
|
||||
return logger
|
||||
} else {
|
||||
logger = Logger{logConfig}
|
||||
loggerMap[logConfig.Name] = logger
|
||||
return logger
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue