I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 9d32e445 authored by str4d's avatar str4d
Browse files

Logger: Configurable flush interval

From i2p.i2p rev 2f451e3579eb5df2d316c1b507950d119d59a8da
parent 42a0d552
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,11 @@ import java.util.Queue;
* @author zzz
*/
class LogWriter implements Runnable {
/** every 10 seconds? why? Just have the gui force a reread after a change?? */
private final static long CONFIG_READ_ITERVAL = 10 * 1000;
final static long FLUSH_INTERVAL = 29 * 1000;
private final static long MIN_FLUSH_INTERVAL = 2*1000;
private final static long MAX_FLUSH_INTERVAL = 5*60*1000;
private long _lastReadConfig = 0;
private long _numBytesInCurrentFile = 0;
private OutputStream _currentOut; // = System.out
......@@ -26,6 +30,8 @@ class LogWriter implements Runnable {
private LogManager _manager;
private boolean _write;
// ms
private volatile long _flushInterval = FLUSH_INTERVAL;
private LogWriter() { // nop
}
......@@ -38,6 +44,14 @@ class LogWriter implements Runnable {
_write = false;
}
/**
* @param interval in ms
* @since 0.9.18
*/
public void setFlushInterval(long interval) {
_flushInterval = Math.min(MAX_FLUSH_INTERVAL, Math.max(MIN_FLUSH_INTERVAL, interval));
}
public void run() {
_write = true;
try {
......@@ -77,7 +91,7 @@ class LogWriter implements Runnable {
if (shouldWait) {
try {
synchronized (this) {
this.wait(10*1000);
this.wait(_flushInterval);
}
} catch (InterruptedException ie) { // nop
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment