Use loggers in some more classes
This commit is contained in:
parent
efabc3c285
commit
a20ab9184e
@ -20,12 +20,17 @@ import java.util.concurrent.Executors;
|
|||||||
|
|
||||||
import io.netty.bootstrap.ServerBootstrap;
|
import io.netty.bootstrap.ServerBootstrap;
|
||||||
import io.netty.channel.socket.nio.NioServerSocketChannelFactory;
|
import io.netty.channel.socket.nio.NioServerSocketChannelFactory;
|
||||||
|
import io.netty.logging.InternalLogger;
|
||||||
|
import io.netty.logging.InternalLoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Web Socket echo server for running the <a href="http://www.tavendo.de/autobahn/testsuite.html">autobahn</a> test
|
* A Web Socket echo server for running the <a href="http://www.tavendo.de/autobahn/testsuite.html">autobahn</a> test
|
||||||
* suite
|
* suite
|
||||||
*/
|
*/
|
||||||
public class AutobahnServer {
|
public class AutobahnServer {
|
||||||
|
|
||||||
|
private static final InternalLogger logger =
|
||||||
|
InternalLoggerFactory.getInstance(AutobahnServer.class);
|
||||||
|
|
||||||
private final int port;
|
private final int port;
|
||||||
|
|
||||||
@ -45,7 +50,7 @@ public class AutobahnServer {
|
|||||||
// Bind and start to accept incoming connections.
|
// Bind and start to accept incoming connections.
|
||||||
bootstrap.bind(new InetSocketAddress(port));
|
bootstrap.bind(new InetSocketAddress(port));
|
||||||
|
|
||||||
System.out.println("Web Socket Server started at port " + port);
|
logger.info("Web Socket Server started at port " + port);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package io.netty.handler.ipfilter;
|
package io.netty.handler.ipfilter;
|
||||||
|
|
||||||
|
import io.netty.logging.InternalLogger;
|
||||||
|
import io.netty.logging.InternalLoggerFactory;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
@ -52,6 +54,10 @@ import java.net.UnknownHostException;
|
|||||||
* where inetAddress2 is 1fff:0:0a88:85a3:0:0:ac1f:8001<BR>
|
* where inetAddress2 is 1fff:0:0a88:85a3:0:0:ac1f:8001<BR>
|
||||||
*/
|
*/
|
||||||
public class IpSubnet implements IpSet, Comparable<IpSubnet> {
|
public class IpSubnet implements IpSet, Comparable<IpSubnet> {
|
||||||
|
|
||||||
|
private static final InternalLogger logger =
|
||||||
|
InternalLoggerFactory.getInstance(IpSubnet.class);
|
||||||
|
|
||||||
/** Internal representation */
|
/** Internal representation */
|
||||||
private CIDR cidr;
|
private CIDR cidr;
|
||||||
|
|
||||||
@ -152,10 +158,10 @@ public class IpSubnet implements IpSet, Comparable<IpSubnet> {
|
|||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
System.out.println("IpSubnet: " + ipSubnet.toString() + " from " + ipSubnet.cidr.getBaseAddress() + " to "
|
logger.debug("IpSubnet: " + ipSubnet.toString() + " from " + ipSubnet.cidr.getBaseAddress() + " to "
|
||||||
+ ipSubnet.cidr.getEndAddress() + " mask " + ipSubnet.cidr.getMask());
|
+ ipSubnet.cidr.getEndAddress() + " mask " + ipSubnet.cidr.getMask());
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
System.out.println("Is IN: " + args[1] + " " + ipSubnet.contains(args[1]));
|
logger.debug("Is IN: " + args[1] + " " + ipSubnet.contains(args[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package io.netty.handler.ipfilter;
|
package io.netty.handler.ipfilter;
|
||||||
|
|
||||||
|
import io.netty.logging.InternalLogger;
|
||||||
|
import io.netty.logging.InternalLoggerFactory;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
@ -40,6 +42,10 @@ import java.util.Vector;
|
|||||||
* where inetAddress is 192.168.1.0 and inetAddress2 is 192.168.1.123<BR>
|
* where inetAddress is 192.168.1.0 and inetAddress2 is 192.168.1.123<BR>
|
||||||
*/
|
*/
|
||||||
public class IpV4Subnet implements IpSet, Comparable<IpV4Subnet> {
|
public class IpV4Subnet implements IpSet, Comparable<IpV4Subnet> {
|
||||||
|
|
||||||
|
private static final InternalLogger logger =
|
||||||
|
InternalLoggerFactory.getInstance(IpV4Subnet.class);
|
||||||
|
|
||||||
private static final int SUBNET_MASK = 0x80000000;
|
private static final int SUBNET_MASK = 0x80000000;
|
||||||
|
|
||||||
private static final int BYTE_ADDRESS_MASK = 0xFF;
|
private static final int BYTE_ADDRESS_MASK = 0xFF;
|
||||||
@ -263,7 +269,7 @@ public class IpV4Subnet implements IpSet, Comparable<IpV4Subnet> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
System.out.println("Is IN: " + args[1] + " " + ipV4Subnet.contains(args[1]));
|
logger.debug("Is IN: " + args[1] + " " + ipV4Subnet.contains(args[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,8 @@ import io.netty.channel.ChildChannelStateEvent;
|
|||||||
import io.netty.channel.ServerChannelFactory;
|
import io.netty.channel.ServerChannelFactory;
|
||||||
import io.netty.channel.SimpleChannelUpstreamHandler;
|
import io.netty.channel.SimpleChannelUpstreamHandler;
|
||||||
import io.netty.channel.socket.SocketChannelConfig;
|
import io.netty.channel.socket.SocketChannelConfig;
|
||||||
|
import io.netty.logging.InternalLogger;
|
||||||
|
import io.netty.logging.InternalLoggerFactory;
|
||||||
import io.netty.testsuite.util.DummyHandler;
|
import io.netty.testsuite.util.DummyHandler;
|
||||||
import io.netty.util.SocketAddresses;
|
import io.netty.util.SocketAddresses;
|
||||||
import io.netty.util.internal.ExecutorUtil;
|
import io.netty.util.internal.ExecutorUtil;
|
||||||
@ -51,6 +53,9 @@ import org.junit.Test;
|
|||||||
* An abstract test class to test server socket bootstraps
|
* An abstract test class to test server socket bootstraps
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractSocketServerBootstrapTest {
|
public abstract class AbstractSocketServerBootstrapTest {
|
||||||
|
|
||||||
|
private static final InternalLogger logger =
|
||||||
|
InternalLoggerFactory.getInstance(AbstractSocketServerBootstrapTest.class);
|
||||||
|
|
||||||
private static final boolean BUFSIZE_MODIFIABLE;
|
private static final boolean BUFSIZE_MODIFIABLE;
|
||||||
|
|
||||||
@ -66,13 +71,11 @@ public abstract class AbstractSocketServerBootstrapTest {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
bufSizeModifiable = false;
|
bufSizeModifiable = false;
|
||||||
System.err.println(
|
logger.error("Socket.getReceiveBufferSize() does not work: " + e);
|
||||||
"Socket.getReceiveBufferSize() does not work: " + e);
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
bufSizeModifiable = false;
|
bufSizeModifiable = false;
|
||||||
System.err.println(
|
logger.error("Socket.setReceiveBufferSize() does not work: " + e);
|
||||||
"Socket.setReceiveBufferSize() does not work: " + e);
|
|
||||||
} finally {
|
} finally {
|
||||||
BUFSIZE_MODIFIABLE = bufSizeModifiable;
|
BUFSIZE_MODIFIABLE = bufSizeModifiable;
|
||||||
try {
|
try {
|
||||||
|
@ -322,8 +322,7 @@ public abstract class AbstractSocketSslEchoTest {
|
|||||||
// You should do something in the real world.
|
// You should do something in the real world.
|
||||||
// You will reach here only if you enabled client certificate auth,
|
// You will reach here only if you enabled client certificate auth,
|
||||||
// as described in SecureChatSslContextFactory.
|
// as described in SecureChatSslContextFactory.
|
||||||
System.err.println(
|
logger.error("UNKNOWN CLIENT CERTIFICATE: " + chain[0].getSubjectDN());
|
||||||
"UNKNOWN CLIENT CERTIFICATE: " + chain[0].getSubjectDN());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -331,8 +330,7 @@ public abstract class AbstractSocketSslEchoTest {
|
|||||||
X509Certificate[] chain, String authType) throws CertificateException {
|
X509Certificate[] chain, String authType) throws CertificateException {
|
||||||
// Always trust - it is an example.
|
// Always trust - it is an example.
|
||||||
// You should do something in the real world.
|
// You should do something in the real world.
|
||||||
System.err.println(
|
logger.error("UNKNOWN SERVER CERTIFICATE: " + chain[0].getSubjectDN());
|
||||||
"UNKNOWN SERVER CERTIFICATE: " + chain[0].getSubjectDN());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -22,6 +22,8 @@ import io.netty.bootstrap.ClientBootstrap;
|
|||||||
import io.netty.bootstrap.ServerBootstrap;
|
import io.netty.bootstrap.ServerBootstrap;
|
||||||
import io.netty.channel.*;
|
import io.netty.channel.*;
|
||||||
import io.netty.channel.sctp.SctpChannelConfig;
|
import io.netty.channel.sctp.SctpChannelConfig;
|
||||||
|
import io.netty.logging.InternalLogger;
|
||||||
|
import io.netty.logging.InternalLoggerFactory;
|
||||||
import io.netty.testsuite.util.DummyHandler;
|
import io.netty.testsuite.util.DummyHandler;
|
||||||
import io.netty.testsuite.util.SctpTestUtil;
|
import io.netty.testsuite.util.SctpTestUtil;
|
||||||
import io.netty.util.internal.ExecutorUtil;
|
import io.netty.util.internal.ExecutorUtil;
|
||||||
@ -46,6 +48,9 @@ import static org.junit.Assert.assertEquals;
|
|||||||
* An abstract test class to test server socket bootstraps
|
* An abstract test class to test server socket bootstraps
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractSocketServerBootstrapTest {
|
public abstract class AbstractSocketServerBootstrapTest {
|
||||||
|
|
||||||
|
private static final InternalLogger logger =
|
||||||
|
InternalLoggerFactory.getInstance(AbstractSocketServerBootstrapTest.class);
|
||||||
|
|
||||||
private static final boolean BUFSIZE_MODIFIABLE;
|
private static final boolean BUFSIZE_MODIFIABLE;
|
||||||
|
|
||||||
@ -58,8 +63,7 @@ public abstract class AbstractSocketServerBootstrapTest {
|
|||||||
bufSizeModifiable = s.supportedOptions().contains(SctpStandardSocketOptions.SO_RCVBUF);
|
bufSizeModifiable = s.supportedOptions().contains(SctpStandardSocketOptions.SO_RCVBUF);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
bufSizeModifiable = false;
|
bufSizeModifiable = false;
|
||||||
System.err.println(
|
logger.error("SCTP SO_RCVBUF does not work: " + e);
|
||||||
"SCTP SO_RCVBUF does not work: " + e);
|
|
||||||
} finally {
|
} finally {
|
||||||
BUFSIZE_MODIFIABLE = bufSizeModifiable;
|
BUFSIZE_MODIFIABLE = bufSizeModifiable;
|
||||||
try {
|
try {
|
||||||
|
@ -312,8 +312,7 @@ public abstract class AbstractSocketSslEchoTest {
|
|||||||
// You should do something in the real world.
|
// You should do something in the real world.
|
||||||
// You will reach here only if you enabled client certificate auth,
|
// You will reach here only if you enabled client certificate auth,
|
||||||
// as described in SecureChatSslContextFactory.
|
// as described in SecureChatSslContextFactory.
|
||||||
System.err.println(
|
logger.error("UNKNOWN CLIENT CERTIFICATE: " + chain[0].getSubjectDN());
|
||||||
"UNKNOWN CLIENT CERTIFICATE: " + chain[0].getSubjectDN());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -321,8 +320,7 @@ public abstract class AbstractSocketSslEchoTest {
|
|||||||
X509Certificate[] chain, String authType) throws CertificateException {
|
X509Certificate[] chain, String authType) throws CertificateException {
|
||||||
// Always trust - it is an example.
|
// Always trust - it is an example.
|
||||||
// You should do something in the real world.
|
// You should do something in the real world.
|
||||||
System.err.println(
|
logger.error("UNKNOWN SERVER CERTIFICATE: " + chain[0].getSubjectDN());
|
||||||
"UNKNOWN SERVER CERTIFICATE: " + chain[0].getSubjectDN());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -887,7 +887,7 @@ abstract class AbstractNioWorker implements Worker {
|
|||||||
if (iothread) {
|
if (iothread) {
|
||||||
fireExceptionCaught(channel, t);
|
fireExceptionCaught(channel, t);
|
||||||
} else {
|
} else {
|
||||||
System.out.println(thread + "==" + channel.getWorker().thread);
|
logger.debug(thread + "==" + channel.getWorker().thread);
|
||||||
fireExceptionCaughtLater(channel, t);
|
fireExceptionCaughtLater(channel, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user