forked from I2P_Developers/i2p.i2p
make the logCloseLoop() methods members of the Log class
so they can be used everywhere
This commit is contained in:
@ -36,7 +36,7 @@ class I2PSocketFull implements I2PSocket {
|
|||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
if (!_closed.compareAndSet(false,true)) {
|
if (!_closed.compareAndSet(false,true)) {
|
||||||
// log a trace to find out why
|
// log a trace to find out why
|
||||||
LogUtil.logCloseLoop(log, "I2PSocket",_localPeer,"-->",_remotePeer,_connection);
|
log.logCloseLoop("I2PSocket",_localPeer,"-->",_remotePeer,_connection);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Connection c = _connection;
|
Connection c = _connection;
|
||||||
|
@ -316,7 +316,7 @@ public class I2PSocketManagerFull implements I2PSocketManager {
|
|||||||
public void destroySocketManager() {
|
public void destroySocketManager() {
|
||||||
if (!_isDestroyed.compareAndSet(false,true)) {
|
if (!_isDestroyed.compareAndSet(false,true)) {
|
||||||
// shouldn't happen, log a stack trace to find out why it happened
|
// shouldn't happen, log a stack trace to find out why it happened
|
||||||
LogUtil.logCloseLoop(_log, "I2PSocketManager", getName());
|
_log.logCloseLoop("I2PSocketManager", getName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_connectionManager.setAllowIncomingConnections(false);
|
_connectionManager.setAllowIncomingConnections(false);
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
package net.i2p.client.streaming;
|
|
||||||
|
|
||||||
import net.i2p.util.Log;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Debug logging utility
|
|
||||||
* @since 0.9.7
|
|
||||||
*/
|
|
||||||
class LogUtil {
|
|
||||||
private LogUtil() {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* logs a loop when closing a resource with level INFO
|
|
||||||
* @param desc vararg description
|
|
||||||
* @param log logger for the class we're intersted in
|
|
||||||
*/
|
|
||||||
static void logCloseLoop(Log log, Object... desc) {
|
|
||||||
logCloseLoop(log, Log.INFO, desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs a close loop when closing a resource
|
|
||||||
* @param desc vararg description of the resource
|
|
||||||
* @param log logger to use
|
|
||||||
* @param level level at which to log
|
|
||||||
*/
|
|
||||||
static void logCloseLoop(Log log, int level, Object... desc) {
|
|
||||||
if (!log.shouldLog(level))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// catenate all toString()s
|
|
||||||
String descString = "close() loop in";
|
|
||||||
for (Object o : desc) {
|
|
||||||
descString += " ";
|
|
||||||
descString += String.valueOf(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
Exception e = new Exception("check stack trace");
|
|
||||||
log.log(level,descString,e);
|
|
||||||
}
|
|
||||||
}
|
|
@ -372,7 +372,7 @@ class MessageOutputStream extends OutputStream {
|
|||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
if (!_closed.compareAndSet(false,true)) {
|
if (!_closed.compareAndSet(false,true)) {
|
||||||
synchronized (_dataLock) { _dataLock.notifyAll(); }
|
synchronized (_dataLock) { _dataLock.notifyAll(); }
|
||||||
LogUtil.logCloseLoop(_log, "MOS");
|
_log.logCloseLoop("MOS");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// setting _closed before flush() will force flush() to send a CLOSE packet
|
// setting _closed before flush() will force flush() to send a CLOSE packet
|
||||||
@ -410,7 +410,7 @@ class MessageOutputStream extends OutputStream {
|
|||||||
*/
|
*/
|
||||||
public void closeInternal() {
|
public void closeInternal() {
|
||||||
if (!_closed.compareAndSet(false,true)) {
|
if (!_closed.compareAndSet(false,true)) {
|
||||||
LogUtil.logCloseLoop(_log, "close internal");
|
_log.logCloseLoop("close internal");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_flusher.cancel();
|
_flusher.cancel();
|
||||||
@ -501,7 +501,7 @@ class MessageOutputStream extends OutputStream {
|
|||||||
|
|
||||||
void destroy() {
|
void destroy() {
|
||||||
if (!_closed.compareAndSet(false,true)) {
|
if (!_closed.compareAndSet(false,true)) {
|
||||||
LogUtil.logCloseLoop(_log, "destroy()");
|
_log.logCloseLoop("destroy()");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_flusher.cancel();
|
_flusher.cancel();
|
||||||
|
@ -184,6 +184,34 @@ public class Log {
|
|||||||
public boolean shouldLog(int priority) {
|
public boolean shouldLog(int priority) {
|
||||||
return priority >= _minPriority;
|
return priority >= _minPriority;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* logs a loop when closing a resource with level INFO
|
||||||
|
* @param desc vararg description
|
||||||
|
*/
|
||||||
|
public void logCloseLoop(Object... desc) {
|
||||||
|
logCloseLoop(Log.INFO, desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs a close loop when closing a resource
|
||||||
|
* @param desc vararg description of the resource
|
||||||
|
* @param level level at which to log
|
||||||
|
*/
|
||||||
|
public void logCloseLoop(int level, Object... desc) {
|
||||||
|
if (!shouldLog(level))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// catenate all toString()s
|
||||||
|
String descString = "close() loop in";
|
||||||
|
for (Object o : desc) {
|
||||||
|
descString += " ";
|
||||||
|
descString += String.valueOf(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
Exception e = new Exception("check stack trace");
|
||||||
|
log(level,descString,e);
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
if (_className != null) return _className;
|
if (_className != null) return _className;
|
||||||
|
Reference in New Issue
Block a user