diff --git a/router/java/src/net/i2p/router/OutNetMessage.java b/router/java/src/net/i2p/router/OutNetMessage.java index 0cc8a7d89afd02981ff7c15f31b6bdcaeb8f5bae..8332a7f1d1a7ab63c424ee794b41dbddfb6b9a32 100644 --- a/router/java/src/net/i2p/router/OutNetMessage.java +++ b/router/java/src/net/i2p/router/OutNetMessage.java @@ -29,7 +29,6 @@ import net.i2p.util.Log; * */ public class OutNetMessage implements CDPQEntry { - private final Log _log; private final RouterContext _context; private final RouterInfo _target; private final I2NPMessage _message; @@ -50,6 +49,7 @@ public class OutNetMessage implements CDPQEntry { private final long _created; private long _enqueueTime; private long _seqNum; + private final boolean _shouldTimestamp; /** for debugging, contains a mapping of even name to Long (e.g. "begin sending", "handleOutbound", etc) */ private HashMap<String, Long> _timestamps; /** @@ -96,7 +96,6 @@ public class OutNetMessage implements CDPQEntry { */ public OutNetMessage(RouterContext context, I2NPMessage msg, long expiration, int priority, RouterInfo target) { _context = context; - _log = context.logManager().getLog(OutNetMessage.class); _message = msg; if (msg != null) { _messageTypeId = msg.getType(); @@ -113,7 +112,9 @@ public class OutNetMessage implements CDPQEntry { //_createdBy = new Exception("Created by"); _created = context.clock().now(); - if (_log.shouldLog(Log.INFO)) + Log log = context.logManager().getLog(OutNetMessage.class); + _shouldTimestamp = log.shouldLog(Log.INFO); + if (_shouldTimestamp) timestamp("Created"); //_context.messageStateMonitor().outboundMessageAdded(); //_context.statManager().createRateStat("outNetMessage.timeToDiscard", @@ -128,10 +129,10 @@ public class OutNetMessage implements CDPQEntry { * @param eventName what occurred * @return how long this message has been 'in flight' */ - public long timestamp(String eventName) { - long now = _context.clock().now(); - if (_log.shouldLog(Log.INFO)) { + public void timestamp(String eventName) { + if (_shouldTimestamp) { // only timestamp if we are debugging + long now = _context.clock().now(); synchronized (this) { locked_initTimestamps(); // ??? @@ -142,13 +143,12 @@ public class OutNetMessage implements CDPQEntry { _timestampOrder.add(eventName); } } - return now - _created; } /** @deprecated unused */ @Deprecated public Map<String, Long> getTimestamps() { - if (_log.shouldLog(Log.INFO)) { + if (_shouldTimestamp) { synchronized (this) { locked_initTimestamps(); return new HashMap<String, Long>(_timestamps); @@ -160,7 +160,7 @@ public class OutNetMessage implements CDPQEntry { /** @deprecated unused */ @Deprecated public Long getTimestamp(String eventName) { - if (_log.shouldLog(Log.INFO)) { + if (_shouldTimestamp) { synchronized (this) { locked_initTimestamps(); return _timestamps.get(eventName); @@ -390,7 +390,7 @@ public class OutNetMessage implements CDPQEntry { buf.append(" with onFailedReply job: ").append(_onFailedReply); if (_onFailedSend != null) buf.append(" with onFailedSend job: ").append(_onFailedSend); - if (_timestamps != null && _timestampOrder != null && _log.shouldLog(Log.INFO)) { + if (_timestamps != null && _timestampOrder != null) { buf.append(" {timestamps: \n"); renderTimestamps(buf); buf.append("}");