Merge pull request #260 from CruzBishop/logger-usage

Replace System.*.println calls with logging
This commit is contained in:
Norman Maurer 2012-04-15 01:22:26 -07:00
commit fa3c9c8eee
10 changed files with 52 additions and 23 deletions

View File

@ -15,12 +15,17 @@
*/
package io.netty.util;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import java.net.InetAddress;
import java.net.UnknownHostException;
public final class SocketAddresses {
public static final InetAddress LOCALHOST;
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(SocketAddresses.class);
static {
// We cache this because some machine takes almost forever to return
@ -36,8 +41,7 @@ public final class SocketAddresses {
try {
localhost = InetAddress.getByAddress(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 });
} catch (UnknownHostException e2) {
System.err.println("Failed to get the localhost.");
e2.printStackTrace();
logger.error("Failed to resolve localhost", e2);
}
}
}

View File

@ -47,9 +47,14 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package io.netty.util.internal.jzlib;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import io.netty.util.internal.jzlib.JZlib.WrapperType;
public final class ZStream {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(ZStream.class);
public byte[] next_in; // next input byte
public int next_in_index;
@ -181,10 +186,10 @@ public final class ZStream {
next_out.length <= next_out_index ||
dstate.pending_buf.length < dstate.pending_out + len ||
next_out.length < next_out_index + len) {
System.out.println(dstate.pending_buf.length + ", " +
logger.info(dstate.pending_buf.length + ", " +
dstate.pending_out + ", " + next_out.length + ", " +
next_out_index + ", " + len);
System.out.println("avail_out=" + avail_out);
logger.info("avail_out=" + avail_out);
}
System.arraycopy(dstate.pending_buf, dstate.pending_out, next_out,

View File

@ -20,12 +20,17 @@ import java.util.concurrent.Executors;
import io.netty.bootstrap.ServerBootstrap;
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
* suite
*/
public class AutobahnServer {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(AutobahnServer.class);
private final int port;
@ -45,7 +50,7 @@ public class AutobahnServer {
// Bind and start to accept incoming connections.
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) {

View File

@ -15,6 +15,8 @@
*/
package io.netty.handler.ipfilter;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import java.net.InetAddress;
import java.net.UnknownHostException;
@ -52,6 +54,10 @@ import java.net.UnknownHostException;
* where inetAddress2 is 1fff:0:0a88:85a3:0:0:ac1f:8001<BR>
*/
public class IpSubnet implements IpSet, Comparable<IpSubnet> {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(IpSubnet.class);
/** Internal representation */
private CIDR cidr;
@ -152,10 +158,10 @@ public class IpSubnet implements IpSet, Comparable<IpSubnet> {
} catch (UnknownHostException e) {
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());
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]));
}
}
}

View File

@ -15,6 +15,8 @@
*/
package io.netty.handler.ipfilter;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import java.net.InetAddress;
import java.net.UnknownHostException;
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>
*/
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 BYTE_ADDRESS_MASK = 0xFF;
@ -263,7 +269,7 @@ public class IpV4Subnet implements IpSet, Comparable<IpV4Subnet> {
return;
}
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]));
}
}
}

View File

@ -37,6 +37,8 @@ import io.netty.channel.ChildChannelStateEvent;
import io.netty.channel.ServerChannelFactory;
import io.netty.channel.SimpleChannelUpstreamHandler;
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.util.SocketAddresses;
import io.netty.util.internal.ExecutorUtil;
@ -51,6 +53,9 @@ import org.junit.Test;
* An abstract test class to test server socket bootstraps
*/
public abstract class AbstractSocketServerBootstrapTest {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(AbstractSocketServerBootstrapTest.class);
private static final boolean BUFSIZE_MODIFIABLE;
@ -66,13 +71,11 @@ public abstract class AbstractSocketServerBootstrapTest {
}
} catch (Exception e) {
bufSizeModifiable = false;
System.err.println(
"Socket.getReceiveBufferSize() does not work: " + e);
logger.error("Socket.getReceiveBufferSize() does not work: " + e);
}
} catch (Exception e) {
bufSizeModifiable = false;
System.err.println(
"Socket.setReceiveBufferSize() does not work: " + e);
logger.error("Socket.setReceiveBufferSize() does not work: " + e);
} finally {
BUFSIZE_MODIFIABLE = bufSizeModifiable;
try {

View File

@ -322,8 +322,7 @@ public abstract class AbstractSocketSslEchoTest {
// You should do something in the real world.
// You will reach here only if you enabled client certificate auth,
// as described in SecureChatSslContextFactory.
System.err.println(
"UNKNOWN CLIENT CERTIFICATE: " + chain[0].getSubjectDN());
logger.error("UNKNOWN CLIENT CERTIFICATE: " + chain[0].getSubjectDN());
}
@Override
@ -331,8 +330,7 @@ public abstract class AbstractSocketSslEchoTest {
X509Certificate[] chain, String authType) throws CertificateException {
// Always trust - it is an example.
// You should do something in the real world.
System.err.println(
"UNKNOWN SERVER CERTIFICATE: " + chain[0].getSubjectDN());
logger.error("UNKNOWN SERVER CERTIFICATE: " + chain[0].getSubjectDN());
}
};

View File

@ -22,6 +22,8 @@ import io.netty.bootstrap.ClientBootstrap;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.*;
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.SctpTestUtil;
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
*/
public abstract class AbstractSocketServerBootstrapTest {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(AbstractSocketServerBootstrapTest.class);
private static final boolean BUFSIZE_MODIFIABLE;
@ -58,8 +63,7 @@ public abstract class AbstractSocketServerBootstrapTest {
bufSizeModifiable = s.supportedOptions().contains(SctpStandardSocketOptions.SO_RCVBUF);
} catch (Throwable e) {
bufSizeModifiable = false;
System.err.println(
"SCTP SO_RCVBUF does not work: " + e);
logger.error("SCTP SO_RCVBUF does not work: " + e);
} finally {
BUFSIZE_MODIFIABLE = bufSizeModifiable;
try {

View File

@ -312,8 +312,7 @@ public abstract class AbstractSocketSslEchoTest {
// You should do something in the real world.
// You will reach here only if you enabled client certificate auth,
// as described in SecureChatSslContextFactory.
System.err.println(
"UNKNOWN CLIENT CERTIFICATE: " + chain[0].getSubjectDN());
logger.error("UNKNOWN CLIENT CERTIFICATE: " + chain[0].getSubjectDN());
}
@Override
@ -321,8 +320,7 @@ public abstract class AbstractSocketSslEchoTest {
X509Certificate[] chain, String authType) throws CertificateException {
// Always trust - it is an example.
// You should do something in the real world.
System.err.println(
"UNKNOWN SERVER CERTIFICATE: " + chain[0].getSubjectDN());
logger.error("UNKNOWN SERVER CERTIFICATE: " + chain[0].getSubjectDN());
}
};

View File

@ -887,7 +887,7 @@ abstract class AbstractNioWorker implements Worker {
if (iothread) {
fireExceptionCaught(channel, t);
} else {
System.out.println(thread + "==" + channel.getWorker().thread);
logger.debug(thread + "==" + channel.getWorker().thread);
fireExceptionCaughtLater(channel, t);
}
}