Merge pull request #261 from CruzBishop/logger-usage

Replace System.out logging with InternalLogger
This commit is contained in:
Norman Maurer 2012-04-15 23:06:14 -07:00
commit f25453cd36
33 changed files with 280 additions and 147 deletions

View File

@ -24,12 +24,17 @@ import io.netty.channel.ChannelPipeline;
import io.netty.channel.ChannelPipelineFactory;
import io.netty.channel.Channels;
import io.netty.channel.socket.nio.NioClientSocketChannelFactory;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
/**
* Keeps sending random data to the specified address.
*/
public class DiscardClient {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(DiscardClient.class);
private final String host;
private final int port;
private final int firstMessageSize;
@ -67,7 +72,7 @@ public class DiscardClient {
public static void main(String[] args) throws Exception {
// Print usage if no argument is specified.
if (args.length < 2 || args.length > 3) {
System.err.println(
logger.error(
"Usage: " + DiscardClient.class.getSimpleName() +
" <host> <port> [<first message size>]");
return;

View File

@ -24,6 +24,8 @@ import io.netty.channel.ChannelPipeline;
import io.netty.channel.ChannelPipelineFactory;
import io.netty.channel.Channels;
import io.netty.channel.socket.nio.NioClientSocketChannelFactory;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
/**
* Sends one message when a connection is open and echoes back any received
@ -33,6 +35,9 @@ import io.netty.channel.socket.nio.NioClientSocketChannelFactory;
*/
public class EchoClient {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(EchoClient.class);
private final String host;
private final int port;
private final int firstMessageSize;
@ -70,7 +75,7 @@ public class EchoClient {
public static void main(String[] args) throws Exception {
// Print usage if no argument is specified.
if (args.length < 2 || args.length > 3) {
System.err.println(
logger.error(
"Usage: " + EchoClient.class.getSimpleName() +
" <host> <port> [<first message size>]");
return;

View File

@ -22,6 +22,8 @@ import io.netty.bootstrap.ClientBootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.socket.nio.NioClientSocketChannelFactory;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
/**
* Sends a sequence of integers to a {@link FactorialServer} to calculate
@ -29,6 +31,9 @@ import io.netty.channel.socket.nio.NioClientSocketChannelFactory;
*/
public class FactorialClient {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(FactorialClient.class);
private final String host;
private final int port;
private final int count;
@ -60,8 +65,7 @@ public class FactorialClient {
(FactorialClientHandler) channel.getPipeline().getLast();
// Print out the answer.
System.err.format(
"Factorial of %,d is: %,d", count, handler.getFactorial());
logger.info(String.format("Factorial of %,d is: %,d", count, handler.getFactorial()));
// Shut down all thread pools to exit.
bootstrap.releaseExternalResources();
@ -70,7 +74,7 @@ public class FactorialClient {
public static void main(String[] args) throws Exception {
// Print usage if no argument is specified.
if (args.length != 3) {
System.err.println(
logger.error(
"Usage: " + FactorialClient.class.getSimpleName() +
" <host> <port> <count>");
return;

View File

@ -54,6 +54,8 @@ import io.netty.handler.codec.http.HttpResponse;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.handler.ssl.SslHandler;
import io.netty.handler.stream.ChunkedFile;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import io.netty.util.CharsetUtil;
/**
@ -104,6 +106,9 @@ import io.netty.util.CharsetUtil;
*/
public class HttpStaticFileServerHandler extends SimpleChannelUpstreamHandler {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(HttpStaticFileServerHandler.class);
public static final String HTTP_DATE_FORMAT = "EEE, dd MMM yyyy HH:mm:ss zzz";
public static final String HTTP_DATE_GMT_TIMEZONE = "GMT";
public static final int HTTP_CACHE_SECONDS = 60;
@ -188,7 +193,7 @@ public class HttpStaticFileServerHandler extends SimpleChannelUpstreamHandler {
@Override
public void operationProgressed(
ChannelFuture future, long amount, long current, long total) {
System.out.printf("%s: %d / %d (+%d)%n", path, current, total, amount);
logger.info(String.format("%s: %d / %d (+%d)%n", path, current, total, amount));
}
});
}

View File

@ -29,6 +29,8 @@ import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.HttpMethod;
import io.netty.handler.codec.http.HttpRequest;
import io.netty.handler.codec.http.HttpVersion;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
/**
* A simple HTTP client that prints out the content of the HTTP response to
@ -36,6 +38,9 @@ import io.netty.handler.codec.http.HttpVersion;
*/
public class HttpSnoopClient {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(HttpSnoopClient.class);
private final URI uri;
public HttpSnoopClient(URI uri) {
@ -55,7 +60,7 @@ public class HttpSnoopClient {
}
if (!scheme.equalsIgnoreCase("http") && !scheme.equalsIgnoreCase("https")) {
System.err.println("Only HTTP(S) is supported.");
logger.error("Only HTTP(S) is supported.");
return;
}
@ -105,7 +110,7 @@ public class HttpSnoopClient {
public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.err.println(
logger.error(
"Usage: " + HttpSnoopClient.class.getSimpleName() +
" <URL>");
return;

View File

@ -21,10 +21,15 @@ import io.netty.channel.MessageEvent;
import io.netty.channel.SimpleChannelUpstreamHandler;
import io.netty.handler.codec.http.HttpChunk;
import io.netty.handler.codec.http.HttpResponse;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import io.netty.util.CharsetUtil;
public class HttpSnoopClientHandler extends SimpleChannelUpstreamHandler {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(HttpSnoopClientHandler.class);
private boolean readingChunks;
@Override
@ -32,38 +37,35 @@ public class HttpSnoopClientHandler extends SimpleChannelUpstreamHandler {
if (!readingChunks) {
HttpResponse response = (HttpResponse) e.getMessage();
System.out.println("STATUS: " + response.getStatus());
System.out.println("VERSION: " + response.getProtocolVersion());
System.out.println();
logger.info("STATUS: " + response.getStatus());
logger.info("VERSION: " + response.getProtocolVersion());
if (!response.getHeaderNames().isEmpty()) {
for (String name: response.getHeaderNames()) {
for (String value: response.getHeaders(name)) {
System.out.println("HEADER: " + name + " = " + value);
logger.info("HEADER: " + name + " = " + value);
}
}
System.out.println();
}
if (response.isChunked()) {
readingChunks = true;
System.out.println("CHUNKED CONTENT {");
logger.info("CHUNKED CONTENT {");
} else {
ChannelBuffer content = response.getContent();
if (content.readable()) {
System.out.println("CONTENT {");
System.out.println(content.toString(CharsetUtil.UTF_8));
System.out.println("} END OF CONTENT");
logger.info("CONTENT {");
logger.info(content.toString(CharsetUtil.UTF_8));
logger.info("} END OF CONTENT");
}
}
} else {
HttpChunk chunk = (HttpChunk) e.getMessage();
if (chunk.isLast()) {
readingChunks = false;
System.out.println("} END OF CHUNKED CONTENT");
logger.info("} END OF CHUNKED CONTENT");
} else {
System.out.print(chunk.getContent().toString(CharsetUtil.UTF_8));
System.out.flush();
logger.info(chunk.getContent().toString(CharsetUtil.UTF_8));
}
}
}

View File

@ -41,11 +41,14 @@ import io.netty.handler.codec.http.HttpRequest;
import io.netty.handler.codec.http.HttpVersion;
import io.netty.handler.codec.http.InterfaceHttpData;
import io.netty.handler.codec.http.QueryStringEncoder;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
/**
*/
public class HttpUploadClient {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(HttpUploadClient.class);
private final String baseUri;
private final String filePath;
@ -69,7 +72,7 @@ public class HttpUploadClient {
try {
uriSimple = new URI(postSimple);
} catch (URISyntaxException e) {
System.err.println("Error: " + e.getMessage());
logger.error("Invalid URI syntax" + e.getCause());
return;
}
String scheme = uriSimple.getScheme() == null? "http" : uriSimple.getScheme();
@ -84,7 +87,7 @@ public class HttpUploadClient {
}
if (!scheme.equalsIgnoreCase("http") && !scheme.equalsIgnoreCase("https")) {
System.err.println("Only HTTP(S) is supported.");
logger.error("Only HTTP(S) is supported.");
return;
}
@ -94,12 +97,12 @@ public class HttpUploadClient {
try {
uriFile = new URI(postFile);
} catch (URISyntaxException e) {
System.err.println("Error: " + e.getMessage());
logger.error("Error: " + e.getMessage());
return;
}
File file = new File(filePath);
if (! file.canRead()) {
System.err.println("A correct path is needed");
logger.error("A correct path is needed");
return;
}
@ -176,7 +179,7 @@ public class HttpUploadClient {
try {
uriGet = new URI(encoder.toString());
} catch (URISyntaxException e) {
System.err.println("Error: " + e.getMessage());
logger.error("Error: " + e.getMessage());
bootstrap.releaseExternalResources();
return null;
}
@ -377,7 +380,7 @@ public class HttpUploadClient {
public static void main(String[] args) {
if (args.length != 2) {
System.err.println(
logger.error(
"Usage: " + HttpUploadClient.class.getSimpleName() +
" baseURI filePath");
return;

View File

@ -22,10 +22,15 @@ import io.netty.channel.MessageEvent;
import io.netty.channel.SimpleChannelUpstreamHandler;
import io.netty.handler.codec.http.HttpChunk;
import io.netty.handler.codec.http.HttpResponse;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import io.netty.util.CharsetUtil;
public class HttpUploadClientHandler extends SimpleChannelUpstreamHandler {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(HttpUploadClientHandler.class);
private volatile boolean readingChunks;
@Override
@ -33,38 +38,35 @@ public class HttpUploadClientHandler extends SimpleChannelUpstreamHandler {
if (!readingChunks) {
HttpResponse response = (HttpResponse) e.getMessage();
System.out.println("STATUS: " + response.getStatus());
System.out.println("VERSION: " + response.getProtocolVersion());
System.out.println();
logger.info("STATUS: " + response.getStatus());
logger.info("VERSION: " + response.getProtocolVersion());
if (!response.getHeaderNames().isEmpty()) {
for (String name: response.getHeaderNames()) {
for (String value: response.getHeaders(name)) {
System.out.println("HEADER: " + name + " = " + value);
logger.info("HEADER: " + name + " = " + value);
}
}
System.out.println();
}
if (response.getStatus().getCode() == 200 && response.isChunked()) {
readingChunks = true;
System.out.println("CHUNKED CONTENT {");
logger.info("CHUNKED CONTENT {");
} else {
ChannelBuffer content = response.getContent();
if (content.readable()) {
System.out.println("CONTENT {");
System.out.println(content.toString(CharsetUtil.UTF_8));
System.out.println("} END OF CONTENT");
logger.info("CONTENT {");
logger.info(content.toString(CharsetUtil.UTF_8));
logger.info("} END OF CONTENT");
}
}
} else {
HttpChunk chunk = (HttpChunk) e.getMessage();
if (chunk.isLast()) {
readingChunks = false;
System.out.println("} END OF CHUNKED CONTENT");
logger.info("} END OF CHUNKED CONTENT");
} else {
System.out.print(chunk.getContent().toString(CharsetUtil.UTF_8));
System.out.flush();
logger.info(chunk.getContent().toString(CharsetUtil.UTF_8));
}
}
}

View File

@ -58,10 +58,15 @@ import io.netty.handler.codec.http.HttpVersion;
import io.netty.handler.codec.http.InterfaceHttpData;
import io.netty.handler.codec.http.InterfaceHttpData.HttpDataType;
import io.netty.handler.codec.http.QueryStringDecoder;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import io.netty.util.CharsetUtil;
public class HttpUploadServerHandler extends SimpleChannelUpstreamHandler {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(HttpUploadServerHandler.class);
private volatile HttpRequest request;
private volatile boolean readingChunks;
@ -480,8 +485,7 @@ public class HttpUploadServerHandler extends SimpleChannelUpstreamHandler {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
e.getCause().printStackTrace();
System.err.println(responseContent.toString());
logger.error(responseContent.toString(), e.getCause());
e.getChannel().close();
}
}

View File

@ -57,9 +57,14 @@ import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker;
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory;
import io.netty.handler.codec.http.websocketx.WebSocketVersion;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
public class WebSocketClient {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(WebSocketClient.class);
private final URI uri;
public WebSocketClient(URI uri) {
@ -101,7 +106,7 @@ public class WebSocketClient {
});
// Connect
System.out.println("WebSocket Client connecting");
logger.info("WebSocket Client connecting");
ChannelFuture future =
bootstrap.connect(
new InetSocketAddress(uri.getHost(), uri.getPort()));
@ -111,17 +116,17 @@ public class WebSocketClient {
handshaker.handshake(ch).awaitUninterruptibly().rethrowIfFailed();
// Send 10 messages and wait for responses
System.out.println("WebSocket Client sending message");
logger.info("WebSocket Client sending message");
for (int i = 0; i < 10; i++) {
ch.write(new TextWebSocketFrame("Message #" + i));
}
// Ping
System.out.println("WebSocket Client sending ping");
logger.info("WebSocket Client sending ping");
ch.write(new PingWebSocketFrame(ChannelBuffers.copiedBuffer(new byte[]{1, 2, 3, 4, 5, 6})));
// Close
System.out.println("WebSocket Client sending close");
logger.info("WebSocket Client sending close");
ch.write(new CloseWebSocketFrame());
// WebSocketClientHandler will close the connection when the server

View File

@ -49,10 +49,15 @@ import io.netty.handler.codec.http.websocketx.PongWebSocketFrame;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker;
import io.netty.handler.codec.http.websocketx.WebSocketFrame;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import io.netty.util.CharsetUtil;
public class WebSocketClientHandler extends SimpleChannelUpstreamHandler {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(WebSocketClientHandler.class);
private final WebSocketClientHandshaker handshaker;
public WebSocketClientHandler(WebSocketClientHandshaker handshaker) {
@ -61,7 +66,7 @@ public class WebSocketClientHandler extends SimpleChannelUpstreamHandler {
@Override
public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
System.out.println("WebSocket Client disconnected!");
logger.debug("WebSocket Client disconnected!");
}
@Override
@ -69,7 +74,7 @@ public class WebSocketClientHandler extends SimpleChannelUpstreamHandler {
Channel ch = ctx.getChannel();
if (!handshaker.isHandshakeComplete()) {
handshaker.finishHandshake(ch, (HttpResponse) e.getMessage());
System.out.println("WebSocket Client connected!");
logger.debug("WebSocket Client connected!");
return;
}
@ -82,11 +87,11 @@ public class WebSocketClientHandler extends SimpleChannelUpstreamHandler {
WebSocketFrame frame = (WebSocketFrame) e.getMessage();
if (frame instanceof TextWebSocketFrame) {
TextWebSocketFrame textFrame = (TextWebSocketFrame) frame;
System.out.println("WebSocket Client received message: " + textFrame.getText());
logger.info("WebSocket Client received message: " + textFrame.getText());
} else if (frame instanceof PongWebSocketFrame) {
System.out.println("WebSocket Client received pong");
logger.info("WebSocket Client received pong");
} else if (frame instanceof CloseWebSocketFrame) {
System.out.println("WebSocket Client received closing");
logger.info("WebSocket Client received closing");
ch.close();
}
}

View File

@ -20,6 +20,8 @@ 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 HTTP server which serves Web Socket requests at:
@ -42,6 +44,9 @@ import io.netty.channel.socket.nio.NioServerSocketChannelFactory;
*/
public class WebSocketServer {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(WebSocketServer.class);
private final int port;
public WebSocketServer(int port) {
@ -58,8 +63,8 @@ public class WebSocketServer {
// Bind and start to accept incoming connections.
bootstrap.bind(new InetSocketAddress(port));
System.out.println("Web socket server started at port " + port + '.');
System.out.println("Open your browser and navigate to http://localhost:" + port + '/');
logger.info("Web socket server started at port " + port + '.');
logger.info("Open your browser and navigate to http://localhost:" + port + '/');
}
public static void main(String[] args) {

View File

@ -20,6 +20,8 @@ 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 HTTP server which serves Web Socket requests at:
@ -41,6 +43,9 @@ import io.netty.channel.socket.nio.NioServerSocketChannelFactory;
*/
public class WebSocketSslServer {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(WebSocketSslServer.class);
private final int port;
public WebSocketSslServer(int port) {
@ -57,8 +62,8 @@ public class WebSocketSslServer {
// Bind and start to accept incoming connections.
bootstrap.bind(new InetSocketAddress(port));
System.out.println("Web socket server started at port " + port + '.');
System.out.println("Open your browser and navigate to https://localhost:" + port + '/');
logger.info("Web socket server started at port " + port + '.');
logger.info("Open your browser and navigate to https://localhost:" + port + '/');
}
public static void main(String[] args) {
@ -71,13 +76,13 @@ public class WebSocketSslServer {
String keyStoreFilePath = System.getProperty("keystore.file.path");
if (keyStoreFilePath == null || keyStoreFilePath.isEmpty()) {
System.out.println("ERROR: System property keystore.file.path not set. Exiting now!");
logger.error("ERROR: System property keystore.file.path not set. Exiting now!");
System.exit(1);
}
String keyStoreFilePassword = System.getProperty("keystore.file.password");
if (keyStoreFilePassword == null || keyStoreFilePassword.isEmpty()) {
System.out.println("ERROR: System property keystore.file.password not set. Exiting now!");
logger.error("ERROR: System property keystore.file.password not set. Exiting now!");
System.exit(1);
}

View File

@ -31,9 +31,14 @@ import io.netty.handler.codec.string.StringEncoder;
import io.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor;
import io.netty.handler.logging.LoggingHandler;
import io.netty.logging.InternalLogLevel;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
public class LocalExampleMultithreaded {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(LocalExampleMultithreaded.class);
private final String port;
public LocalExampleMultithreaded(String port) {
@ -69,12 +74,11 @@ public class LocalExampleMultithreaded {
// Read commands from array
String[] commands = { "First", "Second", "Third", "quit" };
for (int j = 0; j < 5 ; j++) {
System.err.println("Start " + j);
logger.info("Start " + j);
ChannelFuture channelFuture = cb.connect(socketAddress);
channelFuture.awaitUninterruptibly();
if (! channelFuture.isSuccess()) {
System.err.println("CANNOT CONNECT");
channelFuture.getCause().printStackTrace();
logger.error("CANNOT CONNECT", channelFuture.getCause());
break;
}
ChannelFuture lastWriteFuture = null;
@ -90,7 +94,7 @@ public class LocalExampleMultithreaded {
channelFuture.getChannel().close();
// Wait until the connection is closed or the connection attempt fails.
channelFuture.getChannel().getCloseFuture().awaitUninterruptibly();
System.err.println("End " + j);
logger.info("End " + j);
}
// Release all resources

View File

@ -28,9 +28,14 @@ import io.netty.channel.MessageEvent;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.handler.execution.ExecutionHandler;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
public class LocalServerPipelineFactory implements ChannelPipelineFactory {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(LocalServerPipelineFactory.class);
private final ExecutionHandler executionHandler;
public LocalServerPipelineFactory(Executor eventExecutor) {
@ -71,7 +76,7 @@ public class LocalServerPipelineFactory implements ChannelPipelineFactory {
Channels.close(e.getChannel());
return;
}
System.err.println("SERVER:" + msg);
logger.error("SERVER:" + msg);
// Write back
Channels.write(e.getChannel(), msg);
}

View File

@ -26,6 +26,8 @@ import io.netty.bootstrap.ClientBootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.socket.nio.NioClientSocketChannelFactory;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
/**
* Sends a list of continent/city pairs to a {@link LocalTimeServer} to
@ -33,6 +35,9 @@ import io.netty.channel.socket.nio.NioClientSocketChannelFactory;
*/
public class LocalTimeClient {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(LocalTimeClient.class);
private final String host;
private final int port;
private final Collection<String> cities;
@ -76,7 +81,7 @@ public class LocalTimeClient {
Iterator<String> i1 = cities.iterator();
Iterator<String> i2 = response.iterator();
while (i1.hasNext()) {
System.out.format("%28s: %s%n", i1.next(), i2.next());
logger.info(String.format("%28s: %s%n", i1.next(), i2.next()));
}
}
@ -99,10 +104,10 @@ public class LocalTimeClient {
}
private static void printUsage() {
System.err.println(
logger.error(
"Usage: " + LocalTimeClient.class.getSimpleName() +
" <host> <port> <continent/city_name> ...");
System.err.println(
logger.error(
"Example: " + LocalTimeClient.class.getSimpleName() +
" localhost 8080 America/New_York Asia/Seoul");
}
@ -111,7 +116,7 @@ public class LocalTimeClient {
List<String> cities = new ArrayList<String>();
for (int i = offset; i < args.length; i ++) {
if (!args[i].matches("^[_A-Za-z]+/[_A-Za-z]+$")) {
System.err.println("Syntax error: '" + args[i] + "'");
logger.error("Syntax error: '" + args[i] + "'");
printUsage();
return null;
}

View File

@ -24,6 +24,8 @@ import io.netty.example.echo.EchoClient;
import io.netty.handler.codec.serialization.ClassResolvers;
import io.netty.handler.codec.serialization.ObjectDecoder;
import io.netty.handler.codec.serialization.ObjectEncoder;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import java.net.InetSocketAddress;
import java.util.concurrent.Executors;
@ -33,6 +35,9 @@ import java.util.concurrent.Executors;
*/
public class ObjectEchoClient {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(ObjectEchoClient.class);
private final String host;
private final int port;
private final int firstMessageSize;
@ -68,7 +73,7 @@ public class ObjectEchoClient {
public static void main(String[] args) throws Exception {
// Print usage if no argument is specified.
if (args.length < 2 || args.length > 3) {
System.err.println(
logger.error(
"Usage: " + ObjectEchoClient.class.getSimpleName() +
" <host> <port> [<first message size>]");
return;

View File

@ -23,9 +23,14 @@ import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.socket.ClientSocketChannelFactory;
import io.netty.channel.socket.nio.NioClientSocketChannelFactory;
import io.netty.channel.socket.nio.NioServerSocketChannelFactory;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
public class HexDumpProxy {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(HexDumpProxy.class);
private final int localPort;
private final String remoteHost;
private final int remotePort;
@ -37,7 +42,7 @@ public class HexDumpProxy {
}
public void run() {
System.err.println(
logger.info(
"Proxying *:" + localPort + " to " +
remoteHost + ':' + remotePort + " ...");
@ -60,7 +65,7 @@ public class HexDumpProxy {
public static void main(String[] args) throws Exception {
// Validate command line options.
if (args.length != 3) {
System.err.println(
logger.error(
"Usage: " + HexDumpProxy.class.getSimpleName() +
" <local port> <remote host> <remote port>");
return;

View File

@ -28,6 +28,8 @@ import io.netty.channel.socket.DatagramChannelFactory;
import io.netty.channel.socket.nio.NioDatagramChannelFactory;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import io.netty.util.CharsetUtil;
/**
@ -38,6 +40,9 @@ import io.netty.util.CharsetUtil;
*/
public class QuoteOfTheMomentClient {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(QuoteOfTheMomentClient.class);
private final int port;
public QuoteOfTheMomentClient(int port) {
@ -86,7 +91,7 @@ public class QuoteOfTheMomentClient {
// response is received. If the channel is not closed within 5 seconds,
// print an error message and quit.
if (!c.getCloseFuture().awaitUninterruptibly(5000)) {
System.err.println("QOTM request timed out.");
logger.error("QOTM request timed out.");
c.close().awaitUninterruptibly();
}

View File

@ -19,15 +19,20 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ExceptionEvent;
import io.netty.channel.MessageEvent;
import io.netty.channel.SimpleChannelUpstreamHandler;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
public class QuoteOfTheMomentClientHandler extends SimpleChannelUpstreamHandler {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(QuoteOfTheMomentClientHandler.class);
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
throws Exception {
String msg = (String) e.getMessage();
if (msg.startsWith("QOTM: ")) {
System.out.println("Quote of the Moment: " + msg.substring(6));
logger.info("Quote of the Moment: " + msg.substring(6));
e.getChannel().close();
}
}
@ -35,7 +40,7 @@ public class QuoteOfTheMomentClientHandler extends SimpleChannelUpstreamHandler
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
e.getCause().printStackTrace();
logger.error("Exception caught", e.getCause());
e.getChannel().close();
}
}

View File

@ -27,6 +27,8 @@ import io.netty.handler.codec.redis.RedisDecoder;
import io.netty.handler.codec.redis.RedisEncoder;
import io.netty.handler.codec.redis.Reply;
import io.netty.handler.queue.BlockingReadHandler;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import java.io.IOException;
import java.net.InetSocketAddress;
@ -36,6 +38,10 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public final class RedisClient {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(RedisClient.class);
private static final byte[] VALUE = "value".getBytes();
public static void main(String[] args) throws Exception {
@ -56,9 +62,9 @@ public final class RedisClient {
Channel channel = redis.getChannel();
channel.write(new Command("set", "1", "value"));
System.out.print(blockingReadHandler.read());
logger.info(blockingReadHandler.read().toString());
channel.write(new Command("get", "1"));
System.out.print(blockingReadHandler.read());
logger.info(blockingReadHandler.read().toString());
int CALLS = 1000000;
int PIPELINE = 50;
@ -85,7 +91,7 @@ public final class RedisClient {
}
}
long end = System.currentTimeMillis();
System.out.println(CALLS * 1000 / (end - start) + " calls per second");
logger.info(CALLS * 1000 / (end - start) + " calls per second");
}
private static void pipelinedIndividualRequests(BlockingReadHandler<Reply> blockingReadHandler, Channel channel, long CALLS, int PIPELINE) throws IOException, InterruptedException {
@ -101,7 +107,7 @@ public final class RedisClient {
}
}
long end = System.currentTimeMillis();
System.out.println(CALLS * 1000 / (end - start) + " calls per second");
logger.info(CALLS * 1000 / (end - start) + " calls per second");
}
private static void requestResponse(BlockingReadHandler<Reply> blockingReadHandler, Channel channel, int CALLS) throws IOException, InterruptedException {
@ -112,7 +118,7 @@ public final class RedisClient {
blockingReadHandler.read();
}
long end = System.currentTimeMillis();
System.out.println(CALLS * 1000 / (end - start) + " calls per second");
logger.info(CALLS * 1000 / (end - start) + " calls per second");
}
private RedisClient() {

View File

@ -23,6 +23,8 @@ import io.netty.channel.Channels;
import io.netty.channel.sctp.SctpClientSocketChannelFactory;
import io.netty.handler.execution.ExecutionHandler;
import io.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import java.net.InetSocketAddress;
import java.util.concurrent.Executors;
@ -32,6 +34,9 @@ import java.util.concurrent.Executors;
*/
public class SctpClient {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(SctpClient.class);
private final String host;
private final int port;
@ -77,7 +82,7 @@ public class SctpClient {
public static void main(String[] args) throws Exception {
// Print usage if no argument is specified.
if (args.length != 2) {
System.err.println(
logger.error(
"Usage: " + SctpClient.class.getSimpleName() +
" <host> <port>");
return;

View File

@ -26,12 +26,17 @@ import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.socket.nio.NioClientSocketChannelFactory;
import io.netty.example.telnet.TelnetClient;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
/**
* Simple SSL chat client modified from {@link TelnetClient}.
*/
public class SecureChatClient {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(SecureChatClient.class);
private final String host;
private final int port;
@ -96,7 +101,7 @@ public class SecureChatClient {
public static void main(String[] args) throws Exception {
// Print usage if no argument is specified.
if (args.length != 2) {
System.err.println(
logger.error(
"Usage: " + SecureChatClient.class.getSimpleName() +
" <host> <port>");
return;

View File

@ -15,9 +15,7 @@
*/
package io.netty.example.securechat;
import java.util.logging.Level;
import java.util.logging.Logger;
import io.netty.channel.Channel;
import io.netty.channel.ChannelEvent;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelStateEvent;
@ -25,14 +23,16 @@ import io.netty.channel.ExceptionEvent;
import io.netty.channel.MessageEvent;
import io.netty.channel.SimpleChannelUpstreamHandler;
import io.netty.handler.ssl.SslHandler;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
/**
* Handles a client-side channel.
*/
public class SecureChatClientHandler extends SimpleChannelUpstreamHandler {
private static final Logger logger = Logger.getLogger(
SecureChatClientHandler.class.getName());
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(SecureChatClientHandler.class);
@Override
public void handleUpstream(
@ -57,14 +57,13 @@ public class SecureChatClientHandler extends SimpleChannelUpstreamHandler {
@Override
public void messageReceived(
ChannelHandlerContext ctx, MessageEvent e) {
System.err.println(e.getMessage());
logger.error((String) e.getMessage());
}
@Override
public void exceptionCaught(
ChannelHandlerContext ctx, ExceptionEvent e) {
logger.log(
Level.WARNING,
logger.warn(
"Unexpected exception from downstream.",
e.getCause());
e.getChannel().close();

View File

@ -15,6 +15,8 @@
*/
package io.netty.example.securechat;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import java.security.InvalidAlgorithmParameterException;
import java.security.KeyStore;
import java.security.KeyStoreException;
@ -32,6 +34,9 @@ import javax.net.ssl.X509TrustManager;
*/
public class SecureChatTrustManagerFactory extends TrustManagerFactorySpi {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(SecureChatTrustManagerFactory.class);
private static final TrustManager DUMMY_TRUST_MANAGER = new X509TrustManager() {
@Override
public X509Certificate[] getAcceptedIssuers() {
@ -45,7 +50,7 @@ public class SecureChatTrustManagerFactory extends TrustManagerFactorySpi {
// 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(
logger.error(
"UNKNOWN CLIENT CERTIFICATE: " + chain[0].getSubjectDN());
}
@ -54,7 +59,7 @@ public class SecureChatTrustManagerFactory extends TrustManagerFactorySpi {
X509Certificate[] chain, String authType) throws CertificateException {
// Always trust - it is an example.
// You should do something in the real world.
System.err.println(
logger.error(
"UNKNOWN SERVER CERTIFICATE: " + chain[0].getSubjectDN());
}
};

View File

@ -25,12 +25,17 @@ import io.netty.bootstrap.ClientBootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.socket.nio.NioClientSocketChannelFactory;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
/**
* Simplistic telnet client.
*/
public class TelnetClient {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(TelnetClient.class);
private final String host;
private final int port;
@ -95,7 +100,7 @@ public class TelnetClient {
public static void main(String[] args) throws Exception {
// Print usage if no argument is specified.
if (args.length != 2) {
System.err.println(
logger.error(
"Usage: " + TelnetClient.class.getSimpleName() +
" <host> <port>");
return;

View File

@ -15,23 +15,23 @@
*/
package io.netty.example.telnet;
import java.util.logging.Level;
import java.util.logging.Logger;
import io.netty.channel.Channel;
import io.netty.channel.ChannelEvent;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelStateEvent;
import io.netty.channel.ExceptionEvent;
import io.netty.channel.MessageEvent;
import io.netty.channel.SimpleChannelUpstreamHandler;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
/**
* Handles a client-side channel.
*/
public class TelnetClientHandler extends SimpleChannelUpstreamHandler {
private static final Logger logger = Logger.getLogger(
TelnetClientHandler.class.getName());
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(TelnetClientHandler.class);
@Override
public void handleUpstream(
@ -46,14 +46,13 @@ public class TelnetClientHandler extends SimpleChannelUpstreamHandler {
public void messageReceived(
ChannelHandlerContext ctx, MessageEvent e) {
// Print out the line received from the server.
System.err.println(e.getMessage());
logger.info((String) e.getMessage());
}
@Override
public void exceptionCaught(
ChannelHandlerContext ctx, ExceptionEvent e) {
logger.log(
Level.WARNING,
logger.warn(
"Unexpected exception from downstream.",
e.getCause());
e.getChannel().close();

View File

@ -25,6 +25,8 @@ import io.netty.channel.ChannelPipelineFactory;
import io.netty.channel.Channels;
import io.netty.channel.socket.nio.NioClientSocketChannelFactory;
import io.netty.handler.timeout.ReadTimeoutHandler;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import io.netty.util.HashedWheelTimer;
import io.netty.util.Timer;
@ -36,6 +38,9 @@ import io.netty.util.Timer;
*/
public class UptimeClient {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(UptimeClient.class);
// Sleep 5 seconds before a reconnection attempt.
static final int RECONNECT_DELAY = 5;
@ -84,7 +89,7 @@ public class UptimeClient {
public static void main(String[] args) throws Exception {
// Print usage if no argument is specified.
if (args.length != 2) {
System.err.println(
logger.error(
"Usage: " + UptimeClient.class.getSimpleName() +
" <host> <port>");
return;

View File

@ -25,6 +25,8 @@ import io.netty.channel.ChannelStateEvent;
import io.netty.channel.ExceptionEvent;
import io.netty.channel.SimpleChannelUpstreamHandler;
import io.netty.handler.timeout.ReadTimeoutException;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import io.netty.util.Timeout;
import io.netty.util.Timer;
import io.netty.util.TimerTask;
@ -35,6 +37,9 @@ import io.netty.util.TimerTask;
*/
public class UptimeClientHandler extends SimpleChannelUpstreamHandler {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(UptimeClientHandler.class);
final ClientBootstrap bootstrap;
private final Timer timer;
private long startTime = -1;
@ -91,9 +96,9 @@ public class UptimeClientHandler extends SimpleChannelUpstreamHandler {
void println(String msg) {
if (startTime < 0) {
System.err.format("[SERVER IS DOWN] %s%n", msg);
logger.error(String.format("[SERVER IS DOWN] %s%n", msg));
} else {
System.err.format("[UPTIME: %5ds] %s%n", (System.currentTimeMillis() - startTime) / 1000, msg);
logger.error(String.format("[UPTIME: %5ds] %s%n", (System.currentTimeMillis() - startTime) / 1000, msg));
}
}
}

View File

@ -28,8 +28,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Level;
import java.util.logging.Logger;
import io.netty.bootstrap.ClientBootstrap;
import io.netty.bootstrap.ServerBootstrap;
@ -51,6 +49,8 @@ import io.netty.channel.socket.ServerSocketChannelFactory;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioClientSocketChannelFactory;
import io.netty.channel.socket.nio.NioServerSocketChannelFactory;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
/**
* Tests HTTP tunnel soaking
@ -59,8 +59,8 @@ public class HttpTunnelSoakTester {
private static final int SERVER_PORT = 20100;
static final Logger LOG = Logger.getLogger(HttpTunnelSoakTester.class
.getName());
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(HttpTunnelSoakTester.class);
private static final long BYTES_TO_SEND = 1024 * 1024 * 1024;
@ -127,15 +127,14 @@ public class HttpTunnelSoakTester {
clientBootstrap.setOption(
HttpTunnelClientChannelConfig.PROXY_ADDRESS_OPTION,
proxyAddress);
System.out.println("Using " + proxyAddress +
logger.info("Using " + proxyAddress +
" as a proxy for this test run");
} else {
System.err.println("Failed to resolve proxy address " +
logger.error("Failed to resolve proxy address " +
proxyAddress);
}
} else {
System.out
.println("No proxy specified, will connect to server directly");
logger.info("No proxy specified, will connect to server directly");
}
}
@ -197,16 +196,16 @@ public class HttpTunnelSoakTester {
}
public void run() throws InterruptedException {
LOG.info("binding server channel");
logger.info("binding server channel");
Channel serverChannel =
serverBootstrap.bind(new InetSocketAddress(SERVER_PORT));
channels.add(serverChannel);
LOG.log(Level.INFO, "server channel bound to {0}",
serverChannel.getLocalAddress());
logger.info(String.format("server channel bound to {0}",
serverChannel.getLocalAddress()));
SocketChannel clientChannel = createClientChannel();
if (clientChannel == null) {
LOG.severe("no client channel - bailing out");
logger.error("no client channel - bailing out");
return;
}
@ -216,37 +215,37 @@ public class HttpTunnelSoakTester {
executor.execute(c2sDataSender);
if (!c2sDataSender.waitForFinish(5, TimeUnit.MINUTES)) {
LOG.severe("Data send from client to server failed");
logger.error("Data send from client to server failed");
}
if (!s2cDataSender.waitForFinish(5, TimeUnit.MINUTES)) {
LOG.severe("Data send from server to client failed");
logger.error("Data send from server to client failed");
}
LOG.log(Level.INFO, "Waiting for verification to complete");
logger.info("Waiting for verification to complete");
if (!c2sVerifier.waitForCompletion(30L, TimeUnit.SECONDS)) {
LOG.warning("Timed out waiting for verification of client-to-server stream");
logger.warn("Timed out waiting for verification of client-to-server stream");
}
if (!s2cVerifier.waitForCompletion(30L, TimeUnit.SECONDS)) {
LOG.warning("Timed out waiting for verification of server-to-client stream");
logger.warn("Timed out waiting for verification of server-to-client stream");
}
LOG.info("closing client channel");
logger.info("closing client channel");
closeChannel(clientChannel);
LOG.info("server channel status: " +
logger.info("server channel status: " +
(serverChannel.isOpen()? "open" : "closed"));
LOG.info("closing server channel");
logger.info("closing server channel");
closeChannel(serverChannel);
}
private void closeChannel(Channel channel) {
try {
if (!channel.close().await(5L, TimeUnit.SECONDS)) {
LOG.warning("Failed to close connection within reasonable amount of time");
logger.warn("Failed to close connection within reasonable amount of time");
}
} catch (InterruptedException e) {
LOG.severe("Interrupted while closing connection");
logger.error("Interrupted while closing connection");
}
}
@ -258,16 +257,16 @@ public class HttpTunnelSoakTester {
clientBootstrap.connect(serverAddress);
try {
if (!clientChannelFuture.await(1000, TimeUnit.MILLISECONDS)) {
LOG.severe("did not connect within acceptable time period");
logger.error("did not connect within acceptable time period");
return null;
}
} catch (InterruptedException e) {
LOG.severe("Interrupted while waiting for client connect to be established");
logger.error("Interrupted while waiting for client connect to be established");
return null;
}
if (!clientChannelFuture.isSuccess()) {
LOG.log(Level.SEVERE, "did not connect successfully",
logger.error("did not connect successfully",
clientChannelFuture.getCause());
return null;
}
@ -331,9 +330,9 @@ public class HttpTunnelSoakTester {
while (bytesToVerify.readable()) {
byte readByte = bytesToVerify.readByte();
if (readByte != expectedNext) {
LOG.log(Level.SEVERE,
logger.error(String.format(
"{0}: received a byte out of sequence. Expected {1}, got {2}",
new Object[] { name, expectedNext, readByte });
new Object[] { name, expectedNext, readByte }));
System.exit(-1);
return;
}
@ -416,20 +415,20 @@ public class HttpTunnelSoakTester {
@Override
public void run() {
if (!running.compareAndSet(false, true)) {
LOG.log(Level.WARNING,
"{0}: Attempt made to run duplicate sender!", name);
logger.warn(String.format(
"{0}: Attempt made to run duplicate sender!", name));
return;
}
if (finishLatch.getCount() == 0) {
LOG.log(Level.SEVERE,
"{0}: Attempt made to run after completion!", name);
logger.error(String.format(
"{0}: Attempt made to run after completion!", name));
}
if (firstRun) {
firstRun = false;
runStartTime = System.currentTimeMillis();
LOG.log(Level.INFO, "{0}: sending data", name);
logger.info(String.format("{0}: sending data", name));
}
while (totalBytesSent < BYTES_TO_SEND) {
@ -447,22 +446,22 @@ public class HttpTunnelSoakTester {
numWrites ++;
if (numWrites % 100 == 0) {
LOG.log(Level.INFO,
logger.info(String.format(
"{0}: {1} writes dispatched, totalling {2} bytes",
new Object[] { name, numWrites, totalBytesSent });
new Object[] { name, numWrites, totalBytesSent }));
}
}
LOG.log(Level.INFO, "{0}: completed send cycle", name);
logger.info(String.format("{0}: completed send cycle", name));
long runEndTime = System.currentTimeMillis();
long totalTime = runEndTime - runStartTime;
long totalKB = totalBytesSent / 1024;
double rate = totalKB / (totalTime / 1000.0);
LOG.log(Level.INFO, "{0}: Sent {1} bytes", new Object[] { name,
totalBytesSent });
LOG.log(Level.INFO, "{0}: Average throughput: {1} KB/s",
new Object[] { name, rate });
logger.info(String.format("{0}: Sent {1} bytes", new Object[] { name,
totalBytesSent }));
logger.info(String.format("{0}: Average throughput: {1} KB/s",
new Object[] { name, rate }));
finishLatch.countDown();
running.set(false);

View File

@ -35,6 +35,8 @@ import io.netty.channel.sctp.SctpServerSocketChannelFactory;
import io.netty.channel.sctp.codec.SctpFrameDecoder;
import io.netty.channel.sctp.codec.SctpFrameEncoder;
import io.netty.channel.sctp.handler.SimpleSctpChannelHandler;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import io.netty.testsuite.util.SctpTestUtil;
import io.netty.util.internal.ExecutorUtil;
@ -53,6 +55,10 @@ import org.junit.BeforeClass;
import org.junit.Test;
public class SctpMultiHomingEchoTest {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(SctpMultiHomingEchoTest.class);
private static final Random random = new Random();
static final byte[] data = new byte[4096];//could not test ultra jumbo frames
@ -228,7 +234,7 @@ public class SctpMultiHomingEchoTest {
@Override
public void sctpNotificationReceived(ChannelHandlerContext ctx, SctpNotificationEvent event) {
System.out.println("SCTP notification event received :" + event);
logger.info("SCTP notification event received :" + event);
}
}
}

View File

@ -432,11 +432,10 @@ final class NioProviderMetadata {
public static void main(String[] args) throws Exception {
for (Entry<Object, Object> e: System.getProperties().entrySet()) {
System.out.println(e.getKey() + ": " + e.getValue());
logger.debug(e.getKey() + ": " + e.getValue());
}
System.out.println();
System.out.println("Hard-coded Constraint Level: " + CONSTRAINT_LEVEL);
System.out.println(
logger.debug("Hard-coded Constraint Level: " + CONSTRAINT_LEVEL);
logger.debug(
"Auto-detected Constraint Level: " +
new ConstraintLevelAutodetector().autodetect());
}

View File

@ -31,8 +31,14 @@ import io.netty.channel.SimpleChannelUpstreamHandler;
import io.netty.channel.local.DefaultLocalClientChannelFactory;
import io.netty.channel.local.DefaultLocalServerChannelFactory;
import io.netty.channel.local.LocalAddress;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
public class LocalAddressTest {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(LocalAddressTest.class);
private static String LOCAL_ADDR_ID = "test.id";
@Test
@ -157,7 +163,7 @@ public class LocalAddressTest {
ChannelEvent e)
throws Exception {
System.err.println(String.format("Received upstream event '%s'", e));
logger.info(String.format("Received upstream event '%s'", e));
}
}
}