diff --git a/core/java/src/net/i2p/client/I2PSessionImpl.java b/core/java/src/net/i2p/client/I2PSessionImpl.java index 588ded97a..b25935123 100644 --- a/core/java/src/net/i2p/client/I2PSessionImpl.java +++ b/core/java/src/net/i2p/client/I2PSessionImpl.java @@ -147,7 +147,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa _portNum = Integer.parseInt(portNum); } catch (NumberFormatException nfe) { if (_log.shouldLog(Log.WARN)) - _log.warn("Invalid port number specified, defaulting to " + _log.warn(getPrefix() + "Invalid port number specified, defaulting to " + TestServer.LISTEN_PORT, nfe); _portNum = TestServer.LISTEN_PORT; } @@ -172,7 +172,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa if (_log.shouldLog(Log.DEBUG)) _log.debug("Skipping line.* property: " + key); } else if ((key.length() > 255) || (val.length() > 255)) { if (_log.shouldLog(Log.WARN)) - _log.warn("Not passing on property [" + _log.warn(getPrefix() + "Not passing on property [" + key + "] in the session configuration as the value is too long (max = 255): " + val); @@ -222,7 +222,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa _closed = false; long startConnect = _context.clock().now(); try { - if (_log.shouldLog(Log.DEBUG)) _log.debug("connect begin to " + _hostname + ":" + _portNum); + if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "connect begin to " + _hostname + ":" + _portNum); _socket = new Socket(_hostname, _portNum); _out = _socket.getOutputStream(); synchronized (_out) { @@ -230,12 +230,12 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa } InputStream in = _socket.getInputStream(); _reader = new I2CPMessageReader(in, this); - if (_log.shouldLog(Log.DEBUG)) _log.debug("before startReading"); + if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "before startReading"); _reader.startReading(); - if (_log.shouldLog(Log.DEBUG)) _log.debug("Before getDate"); + if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Before getDate"); sendMessage(new GetDateMessage()); - if (_log.shouldLog(Log.DEBUG)) _log.debug("After getDate / begin waiting for a response"); + if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "After getDate / begin waiting for a response"); while (!_dateReceived) { try { synchronized (_dateReceivedLock) { @@ -244,11 +244,11 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa } catch (InterruptedException ie) { } } - if (_log.shouldLog(Log.DEBUG)) _log.debug("After received a SetDate response"); + if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "After received a SetDate response"); - if (_log.shouldLog(Log.DEBUG)) _log.debug("Before producer.connect()"); + if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Before producer.connect()"); _producer.connect(this); - if (_log.shouldLog(Log.DEBUG)) _log.debug("After producer.connect()"); + if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "After producer.connect()"); // wait until we have created a lease set while (_leaseSet == null) { @@ -261,15 +261,15 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa } long connected = _context.clock().now(); if (_log.shouldLog(Log.INFO)) - _log.info("Lease set created with inbound tunnels after " - + (connected - startConnect) - + "ms - ready to participate in the network!"); + _log.info(getPrefix() + "Lease set created with inbound tunnels after " + + (connected - startConnect) + + "ms - ready to participate in the network!"); } catch (UnknownHostException uhe) { _closed = true; - throw new I2PSessionException("Invalid session configuration", uhe); + throw new I2PSessionException(getPrefix() + "Invalid session configuration", uhe); } catch (IOException ioe) { _closed = true; - throw new I2PSessionException("Problem connecting to " + _hostname + " on port " + _portNum, ioe); + throw new I2PSessionException(getPrefix() + "Problem connecting to " + _hostname + " on port " + _portNum, ioe); } } @@ -288,7 +288,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa * Report abuse with regards to the given messageId */ public void reportAbuse(int msgId, int severity) throws I2PSessionException { - if (isClosed()) throw new I2PSessionException("Already closed"); + if (isClosed()) throw new I2PSessionException(getPrefix() + "Already closed"); _producer.reportAbuse(this, msgId, severity); } @@ -328,7 +328,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa byte data[] = msg.getPayload().getUnencryptedData(); if ((data == null) || (data.length <= 0)) { if (_log.shouldLog(Log.ERROR)) - _log.error("addNewMessage of a message with no unencrypted data", + _log.error(getPrefix() + "addNewMessage of a message with no unencrypted data", new Exception("Empty message")); } else { final long size = data.length; @@ -343,7 +343,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa notifier.setDaemon(true); notifier.start(); if (_log.shouldLog(Log.INFO)) - _log.info("Notifier " + nid + " is for session " + _sessionId + ", message " + id + "]"); + _log.info(getPrefix() + "Notifier " + nid + " is for session " + _sessionId + ", message " + id + "]"); } } @@ -355,11 +355,11 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa I2CPMessageHandler handler = _handlerMap.getHandler(message.getType()); if (handler == null) { if (_log.shouldLog(Log.WARN)) - _log.warn("Unknown message or unhandleable message received: type = " + _log.warn(getPrefix() + "Unknown message or unhandleable message received: type = " + message.getType()); } else { if (_log.shouldLog(Log.DEBUG)) - _log.debug("Message received of type " + message.getType() + _log.debug(getPrefix() + "Message received of type " + message.getType() + " to be handled by " + handler); handler.handleMessage(message, this); } @@ -424,11 +424,11 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa message.writeMessage(_out); _out.flush(); } - if (_log.shouldLog(Log.DEBUG)) _log.debug("Message written out and flushed"); + if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Message written out and flushed"); } catch (I2CPMessageException ime) { - throw new I2PSessionException("Error writing out the message", ime); + throw new I2PSessionException(getPrefix() + "Error writing out the message", ime); } catch (IOException ioe) { - throw new I2PSessionException("Error writing out the message", ioe); + throw new I2PSessionException(getPrefix() + "Error writing out the message", ioe); } } @@ -436,7 +436,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa * Pass off the error to the listener */ void propogateError(String msg, Throwable error) { - if (_log.shouldLog(Log.ERROR)) _log.error("Error occurred: " + msg, error); + if (_log.shouldLog(Log.ERROR)) _log.error(getPrefix() + "Error occurred: " + msg, error); if (_sessionListener != null) _sessionListener.errorOccurred(this, msg, error); } @@ -450,7 +450,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa public void destroySession(boolean sendDisconnect) { if (_closed) return; - if (_log.shouldLog(Log.DEBUG)) _log.debug("Destroy the session", new Exception("DestroySession()")); + if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Destroy the session", new Exception("DestroySession()")); if (sendDisconnect) { try { _producer.disconnect(this); @@ -468,7 +468,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa * */ private void closeSocket() { - if (_log.shouldLog(Log.DEBUG)) _log.debug("Closing the socket", new Exception("closeSocket")); + if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Closing the socket", new Exception("closeSocket")); _closed = true; if (_reader != null) _reader.stopReading(); _reader = null; @@ -488,24 +488,24 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa * Recieve notification that the I2CP connection was disconnected */ public void disconnected(I2CPMessageReader reader) { - if (_log.shouldLog(Log.DEBUG)) _log.debug("Disconnected", new Exception("Disconnected")); + if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Disconnected", new Exception("Disconnected")); disconnect(); } protected void disconnect() { if (_closed) return; - if (_log.shouldLog(Log.DEBUG)) _log.debug("Disconnect() called", new Exception("Disconnect")); + if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Disconnect() called", new Exception("Disconnect")); if (shouldReconnect()) { if (reconnect()) { - if (_log.shouldLog(Log.INFO)) _log.info("I2CP reconnection successful"); + if (_log.shouldLog(Log.INFO)) _log.info(getPrefix() + "I2CP reconnection successful"); return; } else { - if (_log.shouldLog(Log.ERROR)) _log.error("I2CP reconnection failed"); + if (_log.shouldLog(Log.ERROR)) _log.error(getPrefix() + "I2CP reconnection failed"); } } if (_log.shouldLog(Log.ERROR)) - _log.error("Disconned from the router, and not trying to reconnect further. I hope you're not hoping anything else will happen"); + _log.error(getPrefix() + "Disconned from the router, and not trying to reconnect further. I hope you're not hoping anything else will happen"); if (_sessionListener != null) _sessionListener.disconnected(this); _closed = true; @@ -525,19 +525,21 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa _totalReconnectAttempts++; } else { if (_log.shouldLog(Log.CRIT)) - _log.log(Log.CRIT, "Max number of reconnects exceeded [" + _log.log(Log.CRIT, getPrefix() + "Max number of reconnects exceeded [" + _totalReconnectAttempts + "], we give up!"); return false; } - if (_log.shouldLog(Log.INFO)) _log.info("Reconnecting..."); + if (_log.shouldLog(Log.INFO)) _log.info(getPrefix() + "Reconnecting..."); for (int i = 0; i < MAX_RECONNECT_ATTEMPTS; i++) { try { connect(); return true; } catch (I2PSessionException ise) { - if (_log.shouldLog(Log.ERROR)) _log.error("Error reconnecting on attempt " + i, ise); + if (_log.shouldLog(Log.ERROR)) _log.error(getPrefix() + "Error reconnecting on attempt " + i, ise); } } return false; } + + protected String getPrefix() { return "[" + (_sessionId == null ? -1 : _sessionId.getSessionId()) + "]: "; } } \ No newline at end of file diff --git a/core/java/src/net/i2p/client/I2PSessionImpl2.java b/core/java/src/net/i2p/client/I2PSessionImpl2.java index 7225a6dba..6e806e001 100644 --- a/core/java/src/net/i2p/client/I2PSessionImpl2.java +++ b/core/java/src/net/i2p/client/I2PSessionImpl2.java @@ -103,19 +103,19 @@ class I2PSessionImpl2 extends I2PSessionImpl { } else if (_context.sessionKeyManager().getAvailableTimeLeft(dest.getPublicKey(), key) < 30 * 1000) { // if we have > 10 tags, but they expire in under 30 seconds, we want more sentTags = createNewTags(50); - if (_log.shouldLog(Log.DEBUG)) _log.debug("Tags are almost expired, adding 50 new ones"); + if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Tags are almost expired, adding 50 new ones"); } SessionKey newKey = null; if (false) // rekey newKey = _context.keyGenerator().generateSessionKey(); long nonce = (long)_context.random().nextInt(Integer.MAX_VALUE); - MessageState state = new MessageState(nonce); + MessageState state = new MessageState(nonce, getPrefix()); state.setKey(key); state.setTags(sentTags); state.setNewKey(newKey); state.setTo(dest); - if (_log.shouldLog(Log.DEBUG)) _log.debug("Setting key = " + key); + if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Setting key = " + key); if (keyUsed != null) { if (newKey != null) @@ -133,7 +133,7 @@ class I2PSessionImpl2 extends I2PSessionImpl { _sendingStates.add(state); } if (_log.shouldLog(Log.DEBUG)) - _log.debug("Adding sending state " + state.getMessageId() + " / " + _log.debug(getPrefix() + "Adding sending state " + state.getMessageId() + " / " + state.getNonce()); _producer.sendMessage(this, dest, nonce, payload, tag, key, sentTags, newKey); state.waitFor(MessageStatusMessage.STATUS_SEND_ACCEPTED, @@ -143,18 +143,18 @@ class I2PSessionImpl2 extends I2PSessionImpl { } boolean found = state.received(MessageStatusMessage.STATUS_SEND_ACCEPTED); if (_log.shouldLog(Log.DEBUG)) - _log.debug("After waitFor sending state " + state.getMessageId().getMessageId() + _log.debug(getPrefix() + "After waitFor sending state " + state.getMessageId().getMessageId() + " / " + state.getNonce() + " found = " + found); if (found) { if (_log.shouldLog(Log.INFO)) - _log.info("Message sent after " + state.getElapsed() + "ms with " + _log.info(getPrefix() + "Message sent after " + state.getElapsed() + "ms with " + payload.length + " bytes"); } else { if (_log.shouldLog(Log.INFO)) - _log.info("Message send failed after " + state.getElapsed() + "ms with " + _log.info(getPrefix() + "Message send failed after " + state.getElapsed() + "ms with " + payload.length + " bytes"); if (_log.shouldLog(Log.ERROR)) - _log.error("Never received *accepted* from the router! dropping and reconnecting"); + _log.error(getPrefix() + "Never received *accepted* from the router! dropping and reconnecting"); disconnect(); return false; } @@ -172,19 +172,19 @@ class I2PSessionImpl2 extends I2PSessionImpl { } else if (_context.sessionKeyManager().getAvailableTimeLeft(dest.getPublicKey(), key) < 30 * 1000) { // if we have > 10 tags, but they expire in under 30 seconds, we want more sentTags = createNewTags(50); - if (_log.shouldLog(Log.DEBUG)) _log.debug("Tags are almost expired, adding 50 new ones"); + if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Tags are almost expired, adding 50 new ones"); } SessionKey newKey = null; if (false) // rekey newKey = _context.keyGenerator().generateSessionKey(); long nonce = (long)_context.random().nextInt(Integer.MAX_VALUE); - MessageState state = new MessageState(nonce); + MessageState state = new MessageState(nonce, getPrefix()); state.setKey(key); state.setTags(sentTags); state.setNewKey(newKey); state.setTo(dest); - if (_log.shouldLog(Log.DEBUG)) _log.debug("Setting key = " + key); + if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Setting key = " + key); if (keyUsed != null) { if (newKey != null) @@ -202,7 +202,7 @@ class I2PSessionImpl2 extends I2PSessionImpl { _sendingStates.add(state); } if (_log.shouldLog(Log.DEBUG)) - _log.debug("Adding sending state " + state.getMessageId() + " / " + _log.debug(getPrefix() + "Adding sending state " + state.getMessageId() + " / " + state.getNonce()); _producer.sendMessage(this, dest, nonce, payload, tag, key, sentTags, newKey); if (isGuaranteed()) @@ -219,7 +219,7 @@ class I2PSessionImpl2 extends I2PSessionImpl { if ((!accepted) || (state.getMessageId() == null)) { if (_log.shouldLog(Log.ERROR)) - _log.error("State with nonce " + state.getNonce() + _log.error(getPrefix() + "State with nonce " + state.getNonce() + " was not accepted? (no messageId!! found=" + found + " msgId=" + state.getMessageId() + ")", new Exception("Race on accept/success status messages, or reconnected?")); @@ -231,16 +231,16 @@ class I2PSessionImpl2 extends I2PSessionImpl { } if (_log.shouldLog(Log.DEBUG)) - _log.debug("After waitFor sending state " + state.getMessageId().getMessageId() + _log.debug(getPrefix() + "After waitFor sending state " + state.getMessageId().getMessageId() + " / " + state.getNonce() + " found = " + found); if (found) { if (_log.shouldLog(Log.INFO)) - _log.info("Message sent after " + state.getElapsed() + "ms with " + _log.info(getPrefix() + "Message sent after " + state.getElapsed() + "ms with " + payload.length + " bytes"); ackTags(state); } else { if (_log.shouldLog(Log.INFO)) - _log.info("Message send failed after " + state.getElapsed() + "ms with " + _log.info(getPrefix() + "Message send failed after " + state.getElapsed() + "ms with " + payload.length + " bytes"); nackTags(state); } @@ -249,7 +249,7 @@ class I2PSessionImpl2 extends I2PSessionImpl { private void ackTags(MessageState state) { if (_log.shouldLog(Log.DEBUG)) - _log.debug("ack tags for msgId " + state.getMessageId() + " / " + _log.debug(getPrefix() + "ack tags for msgId " + state.getMessageId() + " / " + state.getNonce() + " key = " + state.getKey() + ", tags = " + state.getTags()); if ((state.getTags() != null) && (state.getTags().size() > 0)) { @@ -262,26 +262,26 @@ class I2PSessionImpl2 extends I2PSessionImpl { private void nackTags(MessageState state) { if (_log.shouldLog(Log.INFO)) - _log.info("nack tags for msgId " + state.getMessageId() + " / " + state.getNonce() + _log.info(getPrefix() + "nack tags for msgId " + state.getMessageId() + " / " + state.getNonce() + " key = " + state.getKey()); _context.sessionKeyManager().failTags(state.getTo().getPublicKey()); } public void receiveStatus(int msgId, long nonce, int status) { - if (_log.shouldLog(Log.DEBUG)) _log.debug("Received status " + status + " for msgId " + msgId + " / " + nonce); + if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Received status " + status + " for msgId " + msgId + " / " + nonce); MessageState state = null; synchronized (_sendingStates) { for (Iterator iter = _sendingStates.iterator(); iter.hasNext();) { state = (MessageState) iter.next(); - if (_log.shouldLog(Log.DEBUG)) _log.debug("State " + state.getMessageId() + " / " + state.getNonce()); + if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "State " + state.getMessageId() + " / " + state.getNonce()); if (state.getNonce() == nonce) { - if (_log.shouldLog(Log.DEBUG)) _log.debug("Found a matching state"); + if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Found a matching state"); break; } else if ((state.getMessageId() != null) && (state.getMessageId().getMessageId() == msgId)) { - if (_log.shouldLog(Log.DEBUG)) _log.debug("Found a matching state by msgId"); + if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Found a matching state by msgId"); break; } else { - if (_log.shouldLog(Log.DEBUG)) _log.debug("State does not match"); + if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "State does not match"); state = null; } } @@ -296,7 +296,7 @@ class I2PSessionImpl2 extends I2PSessionImpl { state.receive(status); } else { if (_log.shouldLog(Log.INFO)) - _log.info("No matching state for messageId " + msgId + " / " + nonce + _log.info(getPrefix() + "No matching state for messageId " + msgId + " / " + nonce + " w/ status = " + status); } } @@ -319,7 +319,7 @@ class I2PSessionImpl2 extends I2PSessionImpl { MessageState state = (MessageState) iter.next(); state.cancel(); } - if (_log.shouldLog(Log.INFO)) _log.info("Disconnecting " + _sendingStates.size() + " states"); + if (_log.shouldLog(Log.INFO)) _log.info(getPrefix() + "Disconnecting " + _sendingStates.size() + " states"); _sendingStates.clear(); } } diff --git a/core/java/src/net/i2p/client/MessageState.java b/core/java/src/net/i2p/client/MessageState.java index ee7b1aae7..1fe92609e 100644 --- a/core/java/src/net/i2p/client/MessageState.java +++ b/core/java/src/net/i2p/client/MessageState.java @@ -20,6 +20,7 @@ import net.i2p.util.Log; class MessageState { private final static Log _log = new Log(MessageState.class); private long _nonce; + private String _prefix; private MessageId _id; private Set _receivedStatus; private SessionKey _key; @@ -30,8 +31,9 @@ class MessageState { private long _created; private Object _lock = new Object(); - public MessageState(long nonce) { + public MessageState(long nonce, String prefix) { _nonce = nonce; + _prefix = prefix; _id = null; _receivedStatus = new HashSet(); _cancelled = false; @@ -64,7 +66,8 @@ class MessageState { } public void setKey(SessionKey key) { - if (_log.shouldLog(Log.DEBUG)) _log.debug("Setting key [" + _key + "] to [" + key + "]"); + if (_log.shouldLog(Log.DEBUG)) + _log.debug(_prefix + "Setting key [" + _key + "] to [" + key + "]"); _key = key; } @@ -105,11 +108,13 @@ class MessageState { if (_cancelled) return; long timeToWait = expiration - Clock.getInstance().now(); if (timeToWait <= 0) { - if (_log.shouldLog(Log.WARN)) _log.warn("Expired waiting for the status [" + status + "]"); + if (_log.shouldLog(Log.WARN)) + _log.warn(_prefix + "Expired waiting for the status [" + status + "]"); return; } if (isSuccess(status) || isFailure(status)) { - if (_log.shouldLog(Log.DEBUG)) _log.debug("Received a confirm (one way or the other)"); + if (_log.shouldLog(Log.DEBUG)) + _log.debug(_prefix + "Received a confirm (one way or the other)"); return; } if (timeToWait > 5000) { @@ -133,21 +138,22 @@ class MessageState { boolean rv = false; - if (_log.shouldLog(Log.DEBUG)) _log.debug("isSuccess(" + wantedStatus + "): " + received); + if (_log.shouldLog(Log.DEBUG)) + _log.debug(_prefix + "isSuccess(" + wantedStatus + "): " + received); for (Iterator iter = received.iterator(); iter.hasNext();) { Integer val = (Integer) iter.next(); int recv = val.intValue(); switch (recv) { case MessageStatusMessage.STATUS_SEND_BEST_EFFORT_FAILURE: if (_log.shouldLog(Log.WARN)) - _log.warn("Received best effort failure after " + getElapsed() + " from " - + this.toString()); + _log.warn(_prefix + "Received best effort failure after " + getElapsed() + " from " + + toString()); rv = false; break; case MessageStatusMessage.STATUS_SEND_GUARANTEED_FAILURE: if (_log.shouldLog(Log.WARN)) - _log.warn("Received guaranteed failure after " + getElapsed() + " from " - + this.toString()); + _log.warn(_prefix + "Received guaranteed failure after " + getElapsed() + " from " + + toString()); rv = false; break; case MessageStatusMessage.STATUS_SEND_ACCEPTED: @@ -155,35 +161,36 @@ class MessageState { return true; // if we're only looking for accepted, take it directly (don't let any GUARANTEED_* override it) } else { if (_log.shouldLog(Log.DEBUG)) - _log.debug("Got accepted, but we're waiting for more from " - + this.toString()); + _log.debug(_prefix + "Got accepted, but we're waiting for more from " + + toString()); continue; // ignore accepted, as we want something better } case MessageStatusMessage.STATUS_SEND_BEST_EFFORT_SUCCESS: if (_log.shouldLog(Log.DEBUG)) - _log.debug("Received best effort success after " + getElapsed() - + " from " + this.toString()); + _log.debug(_prefix + "Received best effort success after " + getElapsed() + + " from " + toString()); if (wantedStatus == recv) { rv = true; } else { if (_log.shouldLog(Log.DEBUG)) - _log.debug("Not guaranteed success, but best effort after " - + getElapsed() + " will do... from " + this.toString()); + _log.debug(_prefix + "Not guaranteed success, but best effort after " + + getElapsed() + " will do... from " + toString()); rv = true; } break; case MessageStatusMessage.STATUS_SEND_GUARANTEED_SUCCESS: if (_log.shouldLog(Log.DEBUG)) - _log.debug("Received guaranteed success after " + getElapsed() + " from " - + this.toString()); + _log.debug(_prefix + "Received guaranteed success after " + getElapsed() + " from " + + toString()); // even if we're waiting for best effort success, guaranteed is good enough rv = true; break; case -1: continue; default: - if (_log.shouldLog(Log.DEBUG)) _log.debug("Received something else [" + recv + "]..."); + if (_log.shouldLog(Log.DEBUG)) + _log.debug(_prefix + "Received something else [" + recv + "]..."); } } return rv; @@ -197,21 +204,22 @@ class MessageState { } boolean rv = false; - if (_log.shouldLog(Log.DEBUG)) _log.debug("isFailure(" + wantedStatus + "): " + received); + if (_log.shouldLog(Log.DEBUG)) + _log.debug(_prefix + "isFailure(" + wantedStatus + "): " + received); for (Iterator iter = received.iterator(); iter.hasNext();) { Integer val = (Integer) iter.next(); int recv = val.intValue(); switch (recv) { case MessageStatusMessage.STATUS_SEND_BEST_EFFORT_FAILURE: if (_log.shouldLog(Log.DEBUG)) - _log.warn("Received best effort failure after " + getElapsed() + " from " - + this.toString()); + _log.warn(_prefix + "Received best effort failure after " + getElapsed() + " from " + + toString()); rv = true; break; case MessageStatusMessage.STATUS_SEND_GUARANTEED_FAILURE: if (_log.shouldLog(Log.DEBUG)) - _log.warn("Received guaranteed failure after " + getElapsed() + " from " - + this.toString()); + _log.warn(_prefix + "Received guaranteed failure after " + getElapsed() + " from " + + toString()); rv = true; break; case MessageStatusMessage.STATUS_SEND_ACCEPTED: @@ -219,36 +227,37 @@ class MessageState { rv = false; } else { if (_log.shouldLog(Log.DEBUG)) - _log.debug("Got accepted, but we're waiting for more from " - + this.toString()); + _log.debug(_prefix + "Got accepted, but we're waiting for more from " + + toString()); continue; // ignore accepted, as we want something better } break; case MessageStatusMessage.STATUS_SEND_BEST_EFFORT_SUCCESS: if (_log.shouldLog(Log.DEBUG)) - _log.debug("Received best effort success after " + getElapsed() - + " from " + this.toString()); + _log.debug(_prefix + "Received best effort success after " + getElapsed() + + " from " + toString()); if (wantedStatus == recv) { rv = false; } else { if (_log.shouldLog(Log.DEBUG)) - _log.debug("Not guaranteed success, but best effort after " - + getElapsed() + " will do... from " + this.toString()); + _log.debug(_prefix + "Not guaranteed success, but best effort after " + + getElapsed() + " will do... from " + toString()); rv = false; } break; case MessageStatusMessage.STATUS_SEND_GUARANTEED_SUCCESS: if (_log.shouldLog(Log.DEBUG)) - _log.debug("Received guaranteed success after " + getElapsed() + " from " - + this.toString()); + _log.debug(_prefix + "Received guaranteed success after " + getElapsed() + " from " + + toString()); // even if we're waiting for best effort success, guaranteed is good enough rv = false; break; case -1: continue; default: - if (_log.shouldLog(Log.DEBUG)) _log.debug("Received something else [" + recv + "]..."); + if (_log.shouldLog(Log.DEBUG)) + _log.debug(_prefix + "Received something else [" + recv + "]..."); } } return rv;