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

Skip to content
Snippets Groups Projects
Commit ebb6609a authored by zzz's avatar zzz
Browse files

fix SimpleTimer logging

parent 5a1d52d8
No related branches found
No related tags found
No related merge requests found
...@@ -9,12 +9,13 @@ import net.i2p.I2PAppContext; ...@@ -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 { ...@@ -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 { ...@@ -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);
}
} }
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