forked from I2P_Developers/i2p.i2p
fix SimpleTimer logging
This commit is contained in:
@ -9,12 +9,13 @@ import net.i2p.I2PAppContext;
|
|||||||
*/
|
*/
|
||||||
class Executor implements Runnable {
|
class Executor implements Runnable {
|
||||||
private final I2PAppContext _context;
|
private final I2PAppContext _context;
|
||||||
private Log _log;
|
private final Log _log;
|
||||||
private final List _readyEvents;
|
private final List<SimpleTimer.TimedEvent> _readyEvents;
|
||||||
private final SimpleStore runn;
|
private final SimpleStore runn;
|
||||||
|
|
||||||
public Executor(I2PAppContext ctx, Log log, List events, SimpleStore x) {
|
public Executor(I2PAppContext ctx, Log log, List<SimpleTimer.TimedEvent> events, SimpleStore x) {
|
||||||
_context = ctx;
|
_context = ctx;
|
||||||
|
_log = log;
|
||||||
_readyEvents = events;
|
_readyEvents = events;
|
||||||
runn = x;
|
runn = x;
|
||||||
}
|
}
|
||||||
@ -26,7 +27,7 @@ class Executor implements Runnable {
|
|||||||
if (_readyEvents.isEmpty())
|
if (_readyEvents.isEmpty())
|
||||||
try { _readyEvents.wait(); } catch (InterruptedException ie) {}
|
try { _readyEvents.wait(); } catch (InterruptedException ie) {}
|
||||||
if (!_readyEvents.isEmpty())
|
if (!_readyEvents.isEmpty())
|
||||||
evt = (SimpleTimer.TimedEvent)_readyEvents.remove(0);
|
evt = _readyEvents.remove(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evt != null) {
|
if (evt != null) {
|
||||||
@ -34,21 +35,12 @@ class Executor implements Runnable {
|
|||||||
try {
|
try {
|
||||||
evt.timeReached();
|
evt.timeReached();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
log("Executing task " + evt + " exited unexpectedly, please report", t);
|
_log.error("Executing task " + evt + " exited unexpectedly, please report", t);
|
||||||
}
|
}
|
||||||
long time = _context.clock().now() - before;
|
long time = _context.clock().now() - before;
|
||||||
// FIXME _log won't be non-null unless we already had a CRIT
|
if ( (time > 1000) && (_log.shouldLog(Log.WARN)) )
|
||||||
if ( (time > 1000) && (_log != null) && (_log.shouldLog(Log.WARN)) )
|
|
||||||
_log.warn("wtf, event execution took " + time + ": " + evt);
|
_log.warn("wtf, event execution took " + time + ": " + evt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void log(String msg, Throwable t) {
|
|
||||||
synchronized (this) {
|
|
||||||
if (_log == null)
|
|
||||||
_log = I2PAppContext.getGlobalContext().logManager().getLog(SimpleTimer.class);
|
|
||||||
}
|
|
||||||
_log.log(Log.CRIT, msg, t);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user