mirror of https://github.com/zlatinb/muwire
prevent duplicate logs
parent
aa66d14602
commit
edfe301080
|
@ -6,16 +6,31 @@ import net.i2p.util.LogManager
|
||||||
|
|
||||||
class MuWireLogManager extends LogManager {
|
class MuWireLogManager extends LogManager {
|
||||||
|
|
||||||
|
private static final Map<Class<?>, Log> classLogs = new HashMap<>()
|
||||||
|
private static final Map<String, Log> stringLogs = new HashMap<>()
|
||||||
|
|
||||||
MuWireLogManager() {
|
MuWireLogManager() {
|
||||||
super(I2PAppContext.getGlobalContext())
|
super(I2PAppContext.getGlobalContext())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Log getLog(Class<?> cls, String name) {
|
public synchronized Log getLog(Class<?> cls, String name) {
|
||||||
if (cls != null)
|
if (cls != null) {
|
||||||
return new JULLog(cls)
|
Log rv = classLogs.get(cls)
|
||||||
new JULLog(name)
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue