rather than flush any/all log messages 10 times a second, flush log messages once there are 100 of them or 10 seconds have passed, whichever comes first
This commit is contained in:
@ -209,8 +209,18 @@ public class LogManager {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void addRecord(LogRecord record) {
|
void addRecord(LogRecord record) {
|
||||||
|
int numRecords = 0;
|
||||||
synchronized (_records) {
|
synchronized (_records) {
|
||||||
_records.add(record);
|
_records.add(record);
|
||||||
|
numRecords = _records.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (numRecords > 100) {
|
||||||
|
// the writer waits 10 seconds *or* until we tell them to wake up
|
||||||
|
// before rereading the config and writing out any log messages
|
||||||
|
synchronized (_writer) {
|
||||||
|
_writer.notifyAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,12 +72,15 @@ class LogWriter implements Runnable {
|
|||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(100);
|
synchronized (this) {
|
||||||
|
this.wait(10*1000);
|
||||||
|
}
|
||||||
} catch (InterruptedException ie) { // nop
|
} catch (InterruptedException ie) { // nop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void rereadConfig() {
|
private void rereadConfig() {
|
||||||
long now = Clock.getInstance().now();
|
long now = Clock.getInstance().now();
|
||||||
if (now - _lastReadConfig > CONFIG_READ_ITERVAL) {
|
if (now - _lastReadConfig > CONFIG_READ_ITERVAL) {
|
||||||
|
Reference in New Issue
Block a user