mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-06 15:20:54 +03:00
always use class name for making Loggers
This commit is contained in:
@@ -32,8 +32,9 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
*/
|
*/
|
||||||
public class Future<V, T extends Throwable> {
|
public class Future<V, T extends Throwable> {
|
||||||
|
|
||||||
private final Logger log;
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
|
private final String name;
|
||||||
private final ExceptionChainer<T> chainer;
|
private final ExceptionChainer<T> chainer;
|
||||||
private final ReentrantLock lock;
|
private final ReentrantLock lock;
|
||||||
private final Condition cond;
|
private final Condition cond;
|
||||||
@@ -60,7 +61,7 @@ public class Future<V, T extends Throwable> {
|
|||||||
* @param lock lock to use
|
* @param lock lock to use
|
||||||
*/
|
*/
|
||||||
public Future(String name, ExceptionChainer<T> chainer, ReentrantLock lock) {
|
public Future(String name, ExceptionChainer<T> chainer, ReentrantLock lock) {
|
||||||
this.log = LoggerFactory.getLogger("<< " + name + " >>");
|
this.name = name;
|
||||||
this.chainer = chainer;
|
this.chainer = chainer;
|
||||||
this.lock = lock == null ? new ReentrantLock() : lock;
|
this.lock = lock == null ? new ReentrantLock() : lock;
|
||||||
this.cond = this.lock.newCondition();
|
this.cond = this.lock.newCondition();
|
||||||
@@ -74,7 +75,7 @@ public class Future<V, T extends Throwable> {
|
|||||||
public void set(V val) {
|
public void set(V val) {
|
||||||
lock();
|
lock();
|
||||||
try {
|
try {
|
||||||
log.debug("Setting to `{}`", val);
|
log.debug("Setting <<{}>> to `{}`", name, val);
|
||||||
this.val = val;
|
this.val = val;
|
||||||
cond.signalAll();
|
cond.signalAll();
|
||||||
} finally {
|
} finally {
|
||||||
@@ -139,14 +140,14 @@ public class Future<V, T extends Throwable> {
|
|||||||
throw pendingEx;
|
throw pendingEx;
|
||||||
if (val != null)
|
if (val != null)
|
||||||
return val;
|
return val;
|
||||||
log.debug("Awaiting");
|
log.debug("Awaiting <<{}>>", name);
|
||||||
while (val == null && pendingEx == null)
|
while (val == null && pendingEx == null)
|
||||||
if (timeout == 0)
|
if (timeout == 0)
|
||||||
cond.await();
|
cond.await();
|
||||||
else if (!cond.await(timeout, unit))
|
else if (!cond.await(timeout, unit))
|
||||||
throw chainer.chain(new TimeoutException("Timeout expired"));
|
throw chainer.chain(new TimeoutException("Timeout expired"));
|
||||||
if (pendingEx != null) {
|
if (pendingEx != null) {
|
||||||
log.error("Woke to: {}", pendingEx.toString());
|
log.error("<<{}>> woke to: {}", name, pendingEx.toString());
|
||||||
throw pendingEx;
|
throw pendingEx;
|
||||||
}
|
}
|
||||||
return val;
|
return val;
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public class StreamCopier
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Logger log;
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
private final InputStream in;
|
private final InputStream in;
|
||||||
private final OutputStream out;
|
private final OutputStream out;
|
||||||
@@ -103,9 +103,7 @@ public class StreamCopier
|
|||||||
public StreamCopier(String name, InputStream in, OutputStream out) {
|
public StreamCopier(String name, InputStream in, OutputStream out) {
|
||||||
this.in = in;
|
this.in = in;
|
||||||
this.out = out;
|
this.out = out;
|
||||||
|
setName(name);
|
||||||
setName("streamCopier");
|
|
||||||
log = LoggerFactory.getLogger(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public StreamCopier bufSize(int size) {
|
public StreamCopier bufSize(int size) {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public abstract class AbstractChannel
|
|||||||
implements Channel {
|
implements Channel {
|
||||||
|
|
||||||
/** Logger */
|
/** Logger */
|
||||||
protected final Logger log;
|
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
/** Transport layer */
|
/** Transport layer */
|
||||||
protected final Transport trans;
|
protected final Transport trans;
|
||||||
@@ -109,9 +109,7 @@ public abstract class AbstractChannel
|
|||||||
|
|
||||||
id = conn.nextID();
|
id = conn.nextID();
|
||||||
|
|
||||||
log = LoggerFactory.getLogger("chan#" + id);
|
lwin = new Window.Local(conn.getWindowSize(), conn.getMaxPacketSize());
|
||||||
|
|
||||||
lwin = new Window.Local(id, conn.getWindowSize(), conn.getMaxPacketSize());
|
|
||||||
in = new ChannelInputStream(this, trans, lwin);
|
in = new ChannelInputStream(this, trans, lwin);
|
||||||
|
|
||||||
open = new Event<ConnectionException>("chan#" + id + " / " + "open", ConnectionException.chainer, lock);
|
open = new Event<ConnectionException>("chan#" + id + " / " + "open", ConnectionException.chainer, lock);
|
||||||
@@ -120,7 +118,7 @@ public abstract class AbstractChannel
|
|||||||
|
|
||||||
protected void init(int recipient, int remoteWinSize, int remoteMaxPacketSize) {
|
protected void init(int recipient, int remoteWinSize, int remoteMaxPacketSize) {
|
||||||
this.recipient = recipient;
|
this.recipient = recipient;
|
||||||
rwin = new Window.Remote(id, remoteWinSize, remoteMaxPacketSize);
|
rwin = new Window.Remote(remoteWinSize, remoteMaxPacketSize);
|
||||||
out = new ChannelOutputStream(this, trans, rwin);
|
out = new ChannelOutputStream(this, trans, rwin);
|
||||||
log.info("Initialized - {}", this);
|
log.info("Initialized - {}", this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public final class ChannelInputStream
|
|||||||
extends InputStream
|
extends InputStream
|
||||||
implements ErrorNotifiable {
|
implements ErrorNotifiable {
|
||||||
|
|
||||||
private final Logger log;
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
private final Channel chan;
|
private final Channel chan;
|
||||||
private final Transport trans;
|
private final Transport trans;
|
||||||
@@ -71,8 +71,6 @@ public final class ChannelInputStream
|
|||||||
private SSHException error;
|
private SSHException error;
|
||||||
|
|
||||||
public ChannelInputStream(Channel chan, Transport trans, Window.Local win) {
|
public ChannelInputStream(Channel chan, Transport trans, Window.Local win) {
|
||||||
log = LoggerFactory.getLogger("<< chan#" + chan.getID() + " / input stream >>");
|
|
||||||
|
|
||||||
this.chan = chan;
|
this.chan = chan;
|
||||||
this.trans = trans;
|
this.trans = trans;
|
||||||
this.win = win;
|
this.win = win;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
public abstract class Window {
|
public abstract class Window {
|
||||||
|
|
||||||
protected final Logger log;
|
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
protected final Object lock = new Object();
|
protected final Object lock = new Object();
|
||||||
|
|
||||||
@@ -30,8 +30,7 @@ public abstract class Window {
|
|||||||
|
|
||||||
protected int size;
|
protected int size;
|
||||||
|
|
||||||
public Window(int chanID, String kindOfWindow, int initialWinSize, int maxPacketSize) {
|
public Window(int initialWinSize, int maxPacketSize) {
|
||||||
log = LoggerFactory.getLogger("<< chan#" + chanID + " / " + kindOfWindow + " >>");
|
|
||||||
size = initialWinSize;
|
size = initialWinSize;
|
||||||
this.maxPacketSize = maxPacketSize;
|
this.maxPacketSize = maxPacketSize;
|
||||||
}
|
}
|
||||||
@@ -70,8 +69,8 @@ public abstract class Window {
|
|||||||
public static final class Remote
|
public static final class Remote
|
||||||
extends Window {
|
extends Window {
|
||||||
|
|
||||||
public Remote(int chanID, int initialWinSize, int maxPacketSize) {
|
public Remote(int initialWinSize, int maxPacketSize) {
|
||||||
super(chanID, "remote win", initialWinSize, maxPacketSize);
|
super(initialWinSize, maxPacketSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void waitAndConsume(int howMuch)
|
public void waitAndConsume(int howMuch)
|
||||||
@@ -98,8 +97,8 @@ public abstract class Window {
|
|||||||
private final int initialSize;
|
private final int initialSize;
|
||||||
private final int threshold;
|
private final int threshold;
|
||||||
|
|
||||||
public Local(int chanID, int initialWinSize, int maxPacketSize) {
|
public Local(int initialWinSize, int maxPacketSize) {
|
||||||
super(chanID, "local win", initialWinSize, maxPacketSize);
|
super(initialWinSize, maxPacketSize);
|
||||||
this.initialSize = initialWinSize;
|
this.initialSize = initialWinSize;
|
||||||
threshold = Math.min(maxPacketSize * 20, initialSize / 4);
|
threshold = Math.min(maxPacketSize * 20, initialSize / 4);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user