From c4841241965ed8a46e5b6b99d7deb442967c5547 Mon Sep 17 00:00:00 2001 From: str4d Date: Mon, 2 Mar 2015 04:08:40 +0000 Subject: [PATCH] Necessary LogWriter changes after update to 0.9.18 --- app/src/main/java/net/i2p/util/LogWriter.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/i2p/util/LogWriter.java b/app/src/main/java/net/i2p/util/LogWriter.java index 48383c0..dcbea88 100644 --- a/app/src/main/java/net/i2p/util/LogWriter.java +++ b/app/src/main/java/net/i2p/util/LogWriter.java @@ -18,7 +18,11 @@ import i2p.bote.android.Constants; * @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 @@ -28,6 +32,8 @@ class LogWriter implements Runnable { private LogManager _manager; private boolean _write; + // ms + private volatile long _flushInterval = FLUSH_INTERVAL; private LogWriter() { // nop } @@ -40,6 +46,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 { @@ -79,7 +93,7 @@ class LogWriter implements Runnable { if (shouldWait) { try { synchronized (this) { - this.wait(10*1000); + this.wait(_flushInterval); } } catch (InterruptedException ie) { // nop }