|
|
@ -308,7 +308,11 @@ public final class Log {
|
|
|
|
|
|
|
|
|
|
|
|
protected final static logEntry poison = new logEntry();
|
|
|
|
protected final static logEntry poison = new logEntry();
|
|
|
|
protected final static BlockingQueue<logEntry> logQueue = new LinkedBlockingQueue<logEntry>();
|
|
|
|
protected final static BlockingQueue<logEntry> logQueue = new LinkedBlockingQueue<logEntry>();
|
|
|
|
private static logRunner logRunnerThread = null;
|
|
|
|
private final static logRunner logRunnerThread = new logRunner();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static {
|
|
|
|
|
|
|
|
logRunnerThread.start();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected final static class logRunner extends Thread {
|
|
|
|
protected final static class logRunner extends Thread {
|
|
|
|
public logRunner() {
|
|
|
|
public logRunner() {
|
|
|
@ -372,17 +376,14 @@ public final class Log {
|
|
|
|
logger.addHandler(handler);
|
|
|
|
logger.addHandler(handler);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
logRunnerThread = new logRunner();
|
|
|
|
|
|
|
|
logRunnerThread.start();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// redirect uncaught exceptions to logging
|
|
|
|
// redirect uncaught exceptions to logging
|
|
|
|
final Log exceptionLog = new Log("UNCAUGHT-EXCEPTION");
|
|
|
|
final Log exceptionLog = new Log("UNCAUGHT-EXCEPTION");
|
|
|
|
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler(){
|
|
|
|
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler(){
|
|
|
|
public void uncaughtException(final Thread t, final Throwable e) {
|
|
|
|
public void uncaughtException(final Thread t, final Throwable e) {
|
|
|
|
String msg = String.format("Thread %s: %s",t.getName(), e.getMessage());
|
|
|
|
String msg = String.format("Thread %s: %s",t.getName(), e.getMessage());
|
|
|
|
exceptionLog.logSevere(msg, e);
|
|
|
|
exceptionLog.logSevere(msg, e);
|
|
|
|
System.err.print("Exception in thread \"" + t.getName() + "\" ");
|
|
|
|
//System.err.print("Exception in thread \"" + t.getName() + "\" ");
|
|
|
|
e.printStackTrace(System.err);
|
|
|
|
//e.printStackTrace(System.err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|