Skip to content

Commit

Permalink
Use loggers in some more classes
Browse files Browse the repository at this point in the history
  • Loading branch information
CruzBishop committed Apr 15, 2012
1 parent efabc3c commit a20ab91
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@

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;

Expand All @@ -45,7 +50,7 @@ public void run() {
// 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) {
Expand Down
10 changes: 8 additions & 2 deletions handler/src/main/java/io/netty/handler/ipfilter/IpSubnet.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -52,6 +54,10 @@
* 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;

Expand Down Expand Up @@ -152,10 +158,10 @@ public static void main(String[] args) throws Exception {
} 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]));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -40,6 +42,10 @@
* 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;
Expand Down Expand Up @@ -263,7 +269,7 @@ public static void main(String[] args) throws Exception {
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]));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
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;
Expand All @@ -51,6 +53,9 @@
* 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;

Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,17 +322,15 @@ public void checkClientTrusted(
// 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
public void checkServerTrusted(
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());
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
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;
Expand All @@ -46,6 +48,9 @@
* 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;

Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,17 +312,15 @@ public void checkClientTrusted(
// 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
public void checkServerTrusted(
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());
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ public void close(AbstractNioChannel channel, ChannelFuture future) {
if (iothread) {
fireExceptionCaught(channel, t);
} else {
System.out.println(thread + "==" + channel.getWorker().thread);
logger.debug(thread + "==" + channel.getWorker().thread);
fireExceptionCaughtLater(channel, t);
}
}
Expand Down

0 comments on commit a20ab91

Please sign in to comment.