Necessary LogWriter changes after update to 0.9.18
This commit is contained in:
@@ -18,7 +18,11 @@ import i2p.bote.android.Constants;
|
|||||||
* @author zzz
|
* @author zzz
|
||||||
*/
|
*/
|
||||||
class LogWriter implements Runnable {
|
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;
|
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 _lastReadConfig = 0;
|
||||||
private long _numBytesInCurrentFile = 0;
|
private long _numBytesInCurrentFile = 0;
|
||||||
private OutputStream _currentOut; // = System.out
|
private OutputStream _currentOut; // = System.out
|
||||||
@@ -28,6 +32,8 @@ class LogWriter implements Runnable {
|
|||||||
private LogManager _manager;
|
private LogManager _manager;
|
||||||
|
|
||||||
private boolean _write;
|
private boolean _write;
|
||||||
|
// ms
|
||||||
|
private volatile long _flushInterval = FLUSH_INTERVAL;
|
||||||
|
|
||||||
private LogWriter() { // nop
|
private LogWriter() { // nop
|
||||||
}
|
}
|
||||||
@@ -40,6 +46,14 @@ class LogWriter implements Runnable {
|
|||||||
_write = false;
|
_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() {
|
public void run() {
|
||||||
_write = true;
|
_write = true;
|
||||||
try {
|
try {
|
||||||
@@ -79,7 +93,7 @@ class LogWriter implements Runnable {
|
|||||||
if (shouldWait) {
|
if (shouldWait) {
|
||||||
try {
|
try {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
this.wait(10*1000);
|
this.wait(_flushInterval);
|
||||||
}
|
}
|
||||||
} catch (InterruptedException ie) { // nop
|
} catch (InterruptedException ie) { // nop
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user