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 {
|
||||
if (!_closed.compareAndSet(false,true)) {
|
||||
// log a trace to find out why
|
||||
LogUtil.logCloseLoop(log, "I2PSocket",_localPeer,"-->",_remotePeer,_connection);
|
||||
log.logCloseLoop("I2PSocket",_localPeer,"-->",_remotePeer,_connection);
|
||||
return;
|
||||
}
|
||||
Connection c = _connection;
|
||||
|
@ -316,7 +316,7 @@ public class I2PSocketManagerFull implements I2PSocketManager {
|
||||
public void destroySocketManager() {
|
||||
if (!_isDestroyed.compareAndSet(false,true)) {
|
||||
// shouldn't happen, log a stack trace to find out why it happened
|
||||
LogUtil.logCloseLoop(_log, "I2PSocketManager", getName());
|
||||
_log.logCloseLoop("I2PSocketManager", getName());
|
||||
return;
|
||||
}
|
||||
_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 {
|
||||
if (!_closed.compareAndSet(false,true)) {
|
||||
synchronized (_dataLock) { _dataLock.notifyAll(); }
|
||||
LogUtil.logCloseLoop(_log, "MOS");
|
||||
_log.logCloseLoop("MOS");
|
||||
return;
|
||||
}
|
||||
// setting _closed before flush() will force flush() to send a CLOSE packet
|
||||
@ -410,7 +410,7 @@ class MessageOutputStream extends OutputStream {
|
||||
*/
|
||||
public void closeInternal() {
|
||||
if (!_closed.compareAndSet(false,true)) {
|
||||
LogUtil.logCloseLoop(_log, "close internal");
|
||||
_log.logCloseLoop("close internal");
|
||||
return;
|
||||
}
|
||||
_flusher.cancel();
|
||||
@ -501,7 +501,7 @@ class MessageOutputStream extends OutputStream {
|
||||
|
||||
void destroy() {
|
||||
if (!_closed.compareAndSet(false,true)) {
|
||||
LogUtil.logCloseLoop(_log, "destroy()");
|
||||
_log.logCloseLoop("destroy()");
|
||||
return;
|
||||
}
|
||||
_flusher.cancel();
|
||||
|
@ -184,6 +184,34 @@ public class Log {
|
||||
public boolean shouldLog(int priority) {
|
||||
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() {
|
||||
if (_className != null) return _className;
|
||||
|
Reference in New Issue
Block a user