- Remove old debug thread dump in getInstance(String)

- Remove double checking to avoid entering synchronized code in getInstance(String)
- Rename newLog(String) to getFileLogger(String) and clean it up a little bit
This commit is contained in:
hns 2005-06-09 11:46:12 +00:00
parent 23efbd457d
commit 0e2aca1c07

View file

@ -63,18 +63,13 @@ public class Logging extends LogFactory {
if (logname == null) { if (logname == null) {
throw new LogConfigurationException("No logname specified!"); throw new LogConfigurationException("No logname specified!");
} }
if ("event".equals(logname))
Thread.dumpStack();
Logger log = null; Logger log = null;
if ("console".equals(logdir)) { if ("console".equals(logdir)) {
log = consoleLog; log = consoleLog;
} else { } else {
log = (Logger) loggerMap.get(logname); log = getFileLogger(logname);
if (log == null) {
log = newLog(logname);
}
} }
ensureRunning(); ensureRunning();
@ -93,23 +88,17 @@ public class Logging extends LogFactory {
/** /**
* Add a log to the list of logs and * Get a file logger, creating it if it doesn't exist yet.
* create and start the runner thread if necessary.
*/ */
private synchronized Logger newLog(String logname) { private synchronized Logger getFileLogger(String logname) {
// check loggerMap again because only now we are synchronized,
// so another thread may have created a log in the meantime.
Logger log = (Logger) loggerMap.get(logname); Logger log = (Logger) loggerMap.get(logname);
if (log != null) { if (log == null) {
return log; log = new FileLogger(logdir, logname);
loggerMap.put(logname, log);
loggers.add(log);
} }
log = new FileLogger(logdir, logname);
loggerMap.put(logname, log);
loggers.add(log);
return log; return log;
} }