diff --git a/main.go b/main.go index dd5f267..d6c3708 100644 --- a/main.go +++ b/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 + } + }