diff --git a/core/src/main/groovy/com/muwire/core/util/MuWireLogManager.groovy b/core/src/main/groovy/com/muwire/core/util/MuWireLogManager.groovy index f087c8f2..c00ca6fc 100644 --- a/core/src/main/groovy/com/muwire/core/util/MuWireLogManager.groovy +++ b/core/src/main/groovy/com/muwire/core/util/MuWireLogManager.groovy @@ -6,16 +6,31 @@ import net.i2p.util.LogManager class MuWireLogManager extends LogManager { + private static final Map, Log> classLogs = new HashMap<>() + private static final Map stringLogs = new HashMap<>() + MuWireLogManager() { super(I2PAppContext.getGlobalContext()) } @Override - public Log getLog(Class cls, String name) { - if (cls != null) - return new JULLog(cls) - new JULLog(name) + public synchronized Log getLog(Class cls, String name) { + if (cls != null) { + Log rv = classLogs.get(cls) + if (rv == null) { + rv = new JULLog(cls) + classLogs.put(cls, rv) + } + return rv + } + + Log rv = stringLogs.get(name) + if (rv == null) { + rv = new JULLog(name) + stringLogs.put(name, rv) + } + rv } }