Use InternalLogger in our code / Use jul in examples

This commit is contained in:
Trustin Lee 2013-02-11 20:37:31 +09:00
parent 3f16f0b4d2
commit 5218f38ed0
22 changed files with 80 additions and 109 deletions

View File

@ -16,14 +16,15 @@
package io.netty.handler.codec.socks;
import io.netty.channel.embedded.EmbeddedByteChannel;
import io.netty.util.internal.InternalLogger;
import io.netty.util.internal.InternalLoggerFactory;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.Assert.*;
public class SocksAuthResponseDecoderTest {
private static final Logger logger = LoggerFactory.getLogger(SocksAuthResponseDecoderTest.class);
private static final InternalLogger logger = InternalLoggerFactory.getInstance(SocksAuthResponseDecoderTest.class);
private static void testSocksAuthResponseDecoderWithDifferentParams(SocksAuthStatus authStatus){
logger.debug("Testing SocksAuthResponseDecoder with authStatus: "+ authStatus);
SocksAuthResponse msg = new SocksAuthResponse(authStatus);

View File

@ -16,15 +16,15 @@
package io.netty.handler.codec.socks;
import io.netty.channel.embedded.EmbeddedByteChannel;
import io.netty.util.internal.InternalLogger;
import io.netty.util.internal.InternalLoggerFactory;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sun.net.util.IPAddressUtil;
import static org.junit.Assert.*;
public class SocksCmdRequestDecoderTest {
private static final Logger logger = LoggerFactory.getLogger(SocksCmdRequestDecoderTest.class);
private static final InternalLogger logger = InternalLoggerFactory.getInstance(SocksCmdRequestDecoderTest.class);
private static void testSocksCmdRequestDecoderWithDifferentParams(SocksCmdType cmdType, SocksAddressType addressType, String host, int port) {
logger.debug("Testing cmdType: " + cmdType + " addressType: " + addressType + " host: " + host + " port: " + port);

View File

@ -16,14 +16,14 @@
package io.netty.handler.codec.socks;
import io.netty.channel.embedded.EmbeddedByteChannel;
import io.netty.util.internal.InternalLogger;
import io.netty.util.internal.InternalLoggerFactory;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.Assert.*;
public class SocksCmdResponseDecoderTest {
private static final Logger logger = LoggerFactory.getLogger(SocksCmdResponseDecoderTest.class);
private static final InternalLogger logger = InternalLoggerFactory.getInstance(SocksCmdResponseDecoderTest.class);
private static void testSocksCmdResponseDecoderWithDifferentParams(SocksCmdStatus cmdStatus, SocksAddressType addressType){
logger.debug("Testing cmdStatus: " + cmdStatus + " addressType: " + addressType);

View File

@ -25,11 +25,10 @@ import io.netty.example.udt.util.UtilConsoleReporter;
import io.netty.example.udt.util.UtilThreadFactory;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
/**
* UDT Byte Stream Client
@ -41,8 +40,7 @@ import java.util.concurrent.TimeUnit;
*/
public class ByteEchoClient {
private static final Logger log = LoggerFactory
.getLogger(ByteEchoClient.class);
private static final Logger log = Logger.getLogger(ByteEchoClient.class.getName());
private final String host;
private final int port;

View File

@ -15,6 +15,8 @@
*/
package io.netty.example.udt.echo.bytes;
import com.yammer.metrics.Metrics;
import com.yammer.metrics.core.Meter;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
@ -23,12 +25,8 @@ import io.netty.channel.ChannelOption;
import io.netty.channel.udt.nio.NioUdtProvider;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.yammer.metrics.Metrics;
import com.yammer.metrics.core.Meter;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Handler implementation for the echo client. It initiates the ping-pong
@ -37,8 +35,7 @@ import com.yammer.metrics.core.Meter;
*/
public class ByteEchoClientHandler extends ChannelInboundByteHandlerAdapter {
private static final Logger log = LoggerFactory
.getLogger(ByteEchoClientHandler.class.getName());
private static final Logger log = Logger.getLogger(ByteEchoClientHandler.class.getName());
private final ByteBuf message;
@ -55,8 +52,7 @@ public class ByteEchoClientHandler extends ChannelInboundByteHandlerAdapter {
@Override
public void channelActive(final ChannelHandlerContext ctx) throws Exception {
log.info("ECHO active {}", NioUdtProvider.socketUDT(ctx.channel())
.toStringOptions());
log.info("ECHO active " + NioUdtProvider.socketUDT(ctx.channel()).toStringOptions());
ctx.write(message);
}
@ -73,7 +69,7 @@ public class ByteEchoClientHandler extends ChannelInboundByteHandlerAdapter {
@Override
public void exceptionCaught(final ChannelHandlerContext ctx,
final Throwable cause) {
log.error("close the connection when an exception is raised", cause);
log.log(Level.WARNING, "close the connection when an exception is raised", cause);
ctx.close();
}

View File

@ -25,10 +25,9 @@ import io.netty.channel.udt.nio.NioUdtProvider;
import io.netty.example.udt.util.UtilThreadFactory;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.ThreadFactory;
import java.util.logging.Logger;
/**
* UDT Byte Stream Server
@ -37,8 +36,7 @@ import java.util.concurrent.ThreadFactory;
*/
public class ByteEchoServer {
private static final Logger log = LoggerFactory
.getLogger(ByteEchoServer.class);
private static final Logger log = Logger.getLogger(ByteEchoServer.class.getName());
private final int port;

View File

@ -22,8 +22,8 @@ import io.netty.channel.ChannelInboundByteHandlerAdapter;
import io.netty.channel.ChannelOption;
import io.netty.channel.udt.nio.NioUdtProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Handler implementation for the echo server.
@ -31,8 +31,7 @@ import org.slf4j.LoggerFactory;
@Sharable
public class ByteEchoServerHandler extends ChannelInboundByteHandlerAdapter {
private static final Logger log = LoggerFactory
.getLogger(ByteEchoServerHandler.class.getName());
private static final Logger log = Logger.getLogger(ByteEchoServerHandler.class.getName());
@Override
public void inboundBufferUpdated(final ChannelHandlerContext ctx,
@ -46,14 +45,13 @@ public class ByteEchoServerHandler extends ChannelInboundByteHandlerAdapter {
@Override
public void exceptionCaught(final ChannelHandlerContext ctx,
final Throwable cause) {
log.error("close the connection when an exception is raised", cause);
log.log(Level.WARNING, "close the connection when an exception is raised", cause);
ctx.close();
}
@Override
public void channelActive(final ChannelHandlerContext ctx) throws Exception {
log.info("ECHO active {}", NioUdtProvider.socketUDT(ctx.channel())
.toStringOptions());
log.info("ECHO active " + NioUdtProvider.socketUDT(ctx.channel()).toStringOptions());
}
@Override

View File

@ -25,11 +25,10 @@ import io.netty.example.udt.util.UtilConsoleReporter;
import io.netty.example.udt.util.UtilThreadFactory;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
/**
* UDT Message Flow client
@ -41,8 +40,7 @@ import java.util.concurrent.TimeUnit;
*/
public class MsgEchoClient {
private static final Logger log = LoggerFactory
.getLogger(MsgEchoClient.class);
private static final Logger log = Logger.getLogger(MsgEchoClient.class.getName());
private final String host;
private final int port;

View File

@ -15,6 +15,8 @@
*/
package io.netty.example.udt.echo.message;
import com.yammer.metrics.Metrics;
import com.yammer.metrics.core.Meter;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.MessageBuf;
import io.netty.buffer.Unpooled;
@ -24,12 +26,8 @@ import io.netty.channel.udt.UdtMessage;
import io.netty.channel.udt.nio.NioUdtProvider;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.yammer.metrics.Metrics;
import com.yammer.metrics.core.Meter;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Handler implementation for the echo client. It initiates the ping-pong
@ -39,8 +37,7 @@ import com.yammer.metrics.core.Meter;
public class MsgEchoClientHandler extends
ChannelInboundMessageHandlerAdapter<UdtMessage> {
private static final Logger log = LoggerFactory
.getLogger(MsgEchoClientHandler.class.getName());
private static final Logger log = Logger.getLogger(MsgEchoClientHandler.class.getName());
private final UdtMessage message;
@ -57,8 +54,7 @@ public class MsgEchoClientHandler extends
@Override
public void channelActive(final ChannelHandlerContext ctx) throws Exception {
log.info("ECHO active {}", NioUdtProvider.socketUDT(ctx.channel())
.toStringOptions());
log.info("ECHO active " + NioUdtProvider.socketUDT(ctx.channel()).toStringOptions());
final MessageBuf<Object> out = ctx.nextOutboundMessageBuffer();
out.add(message);
ctx.flush();
@ -67,7 +63,7 @@ public class MsgEchoClientHandler extends
@Override
public void exceptionCaught(final ChannelHandlerContext ctx,
final Throwable cause) {
log.error("close the connection when an exception is raised", cause);
log.log(Level.WARNING, "close the connection when an exception is raised", cause);
ctx.close();
}

View File

@ -25,10 +25,9 @@ import io.netty.channel.udt.nio.NioUdtProvider;
import io.netty.example.udt.util.UtilThreadFactory;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.ThreadFactory;
import java.util.logging.Logger;
/**
* UDT Message Flow Server
@ -37,8 +36,7 @@ import java.util.concurrent.ThreadFactory;
*/
public class MsgEchoServer {
private static final Logger log = LoggerFactory
.getLogger(MsgEchoServer.class);
private static final Logger log = Logger.getLogger(MsgEchoServer.class.getName());
private final int port;

View File

@ -21,8 +21,9 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.channel.udt.UdtMessage;
import io.netty.channel.udt.nio.NioUdtProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Handler implementation for the echo server.
@ -31,20 +32,18 @@ import org.slf4j.LoggerFactory;
public class MsgEchoServerHandler extends
ChannelInboundMessageHandlerAdapter<UdtMessage> {
private static final Logger log = LoggerFactory
.getLogger(MsgEchoServerHandler.class.getName());
private static final Logger log = Logger.getLogger(MsgEchoServerHandler.class.getName());
@Override
public void exceptionCaught(final ChannelHandlerContext ctx,
final Throwable cause) {
log.error("close the connection when an exception is raised", cause);
log.log(Level.WARNING, "close the connection when an exception is raised", cause);
ctx.close();
}
@Override
public void channelActive(final ChannelHandlerContext ctx) throws Exception {
log.info("ECHO active {}", NioUdtProvider.socketUDT(ctx.channel())
.toStringOptions());
log.info("ECHO active " + NioUdtProvider.socketUDT(ctx.channel()).toStringOptions());
}
@Override
@ -54,5 +53,4 @@ public class MsgEchoServerHandler extends
out.add(message);
ctx.flush();
}
}

View File

@ -19,13 +19,11 @@ import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.udt.UdtChannel;
import io.netty.channel.udt.nio.NioUdtProvider;
import io.netty.example.udt.util.UtilThreadFactory;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import io.netty.channel.udt.UdtChannel;
import io.netty.channel.udt.nio.NioUdtProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.InetSocketAddress;
import java.util.concurrent.ThreadFactory;
@ -38,9 +36,6 @@ import java.util.concurrent.ThreadFactory;
*/
public abstract class MsgEchoPeerBase {
protected static final Logger log = LoggerFactory
.getLogger(MsgEchoPeerBase.class);
protected final int messageSize;
protected final InetSocketAddress self;
protected final InetSocketAddress peer;

View File

@ -15,6 +15,8 @@
*/
package io.netty.example.udt.echo.rendevous;
import com.yammer.metrics.Metrics;
import com.yammer.metrics.core.Meter;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.MessageBuf;
import io.netty.buffer.Unpooled;
@ -24,12 +26,8 @@ import io.netty.channel.udt.UdtMessage;
import io.netty.channel.udt.nio.NioUdtProvider;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.yammer.metrics.Metrics;
import com.yammer.metrics.core.Meter;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Handler implementation for the echo peer. It initiates the ping-pong traffic
@ -39,8 +37,7 @@ import com.yammer.metrics.core.Meter;
public class MsgEchoPeerHandler extends
ChannelInboundMessageHandlerAdapter<UdtMessage> {
private static final Logger log = LoggerFactory
.getLogger(MsgEchoPeerHandler.class.getName());
private static final Logger log = Logger.getLogger(MsgEchoPeerHandler.class.getName());
private final UdtMessage message;
@ -57,8 +54,7 @@ public class MsgEchoPeerHandler extends
@Override
public void channelActive(final ChannelHandlerContext ctx) throws Exception {
log.info("ECHO active {}", NioUdtProvider.socketUDT(ctx.channel())
.toStringOptions());
log.info("ECHO active " + NioUdtProvider.socketUDT(ctx.channel()).toStringOptions());
final MessageBuf<Object> out = ctx.nextOutboundMessageBuffer();
out.add(message);
ctx.flush();
@ -67,7 +63,7 @@ public class MsgEchoPeerHandler extends
@Override
public void exceptionCaught(final ChannelHandlerContext ctx,
final Throwable cause) {
log.error("close the connection when an exception is raised", cause);
log.log(Level.WARNING, "close the connection when an exception is raised", cause);
ctx.close();
}

View File

@ -16,6 +16,7 @@
package io.netty.example.udt.echo.rendevous;
import java.net.InetSocketAddress;
import java.util.logging.Logger;
/**
* UDT Message Flow Peer
@ -25,6 +26,8 @@ import java.net.InetSocketAddress;
*/
public class MsgEchoPeerOne extends MsgEchoPeerBase {
private static final Logger log = Logger.getLogger(MsgEchoPeerOne.class.getName());
public MsgEchoPeerOne(final InetSocketAddress self,
final InetSocketAddress peer, final int messageSize) {
super(self, peer, messageSize);

View File

@ -19,6 +19,7 @@ import io.netty.example.udt.util.UtilConsoleReporter;
import java.net.InetSocketAddress;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
/**
* UDT Message Flow Peer
@ -28,6 +29,8 @@ import java.util.concurrent.TimeUnit;
*/
public class MsgEchoPeerTwo extends MsgEchoPeerBase {
private static final Logger log = Logger.getLogger(MsgEchoPeerTwo.class.getName());
public MsgEchoPeerTwo(final InetSocketAddress self,
final InetSocketAddress peer, final int messageSize) {
super(self, peer, messageSize);

View File

@ -27,9 +27,8 @@ import io.netty.test.udt.util.CustomReporter;
import io.netty.test.udt.util.EchoMessageHandler;
import io.netty.test.udt.util.TrafficControl;
import io.netty.test.udt.util.UnitHelp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.netty.util.internal.InternalLogger;
import io.netty.util.internal.InternalLoggerFactory;
import java.net.InetSocketAddress;
import java.util.concurrent.TimeUnit;
@ -43,7 +42,7 @@ public final class UdtNetty {
private UdtNetty() {
}
static final Logger log = LoggerFactory.getLogger(UdtNetty.class);
static final InternalLogger log = InternalLoggerFactory.getInstance(UdtNetty.class);
/** benchmark duration */
static final int time = 10 * 60 * 1000;

View File

@ -17,8 +17,8 @@
package io.netty.test.udt.util;
import com.google.caliper.SimpleBenchmark;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.netty.util.internal.InternalLogger;
import io.netty.util.internal.InternalLoggerFactory;
/**
* Base class for caliper/metrics benchmarks.
@ -41,7 +41,7 @@ public abstract class CaliperBench extends SimpleBenchmark {
});
}
protected final Logger log = LoggerFactory.getLogger(getClass());
protected final InternalLogger log = InternalLoggerFactory.getInstance(getClass());
private volatile CaliperMeasure measure;

View File

@ -28,8 +28,8 @@ import com.google.caliper.Scenario;
import com.google.caliper.ScenarioResult;
import com.google.caliper.SimpleBenchmark;
import com.yammer.metrics.core.TimerContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.netty.util.internal.InternalLogger;
import io.netty.util.internal.InternalLoggerFactory;
import java.lang.reflect.Method;
import java.util.ArrayList;
@ -50,8 +50,7 @@ import java.util.TreeSet;
*/
public final class CaliperRunner {
private final static Logger log = LoggerFactory
.getLogger(CaliperRunner.class);
private final static InternalLogger log = InternalLoggerFactory.getInstance(CaliperRunner.class);
private CaliperRunner() {
}

View File

@ -16,17 +16,15 @@
package io.netty.test.udt.util;
import com.yammer.metrics.core.Meter;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundByteHandlerAdapter;
import io.netty.channel.ChannelOption;
import io.netty.channel.udt.nio.NioUdtProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.yammer.metrics.core.Meter;
import io.netty.util.internal.InternalLogger;
import io.netty.util.internal.InternalLoggerFactory;
/**
* Handler implementation for the echo client. It initiates the ping-pong
@ -35,8 +33,7 @@ import com.yammer.metrics.core.Meter;
*/
public class EchoByteHandler extends ChannelInboundByteHandlerAdapter {
private static final Logger log = LoggerFactory
.getLogger(EchoByteHandler.class.getName());
private static final InternalLogger log = InternalLoggerFactory.getInstance(EchoByteHandler.class);
private final ByteBuf message;

View File

@ -24,8 +24,8 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.channel.udt.UdtMessage;
import io.netty.channel.udt.nio.NioUdtProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.netty.util.internal.InternalLogger;
import io.netty.util.internal.InternalLoggerFactory;
/**
* Handler implementation for the echo peer. It initiates the ping-pong traffic
@ -35,8 +35,7 @@ import org.slf4j.LoggerFactory;
public class EchoMessageHandler extends
ChannelInboundMessageHandlerAdapter<UdtMessage> {
private static final Logger log = LoggerFactory
.getLogger(EchoMessageHandler.class.getName());
private static final InternalLogger log = InternalLoggerFactory.getInstance(EchoMessageHandler.class);
private final Meter meter;
private final UdtMessage message;

View File

@ -16,8 +16,8 @@
package io.netty.test.udt.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.netty.util.internal.InternalLogger;
import io.netty.util.internal.InternalLoggerFactory;
/**
* Introduce traffic control, such as transfer latency.
@ -28,8 +28,7 @@ import org.slf4j.LoggerFactory;
*/
public final class TrafficControl {
private static final Logger log = LoggerFactory
.getLogger(TrafficControl.class.getName());
private static final InternalLogger log = InternalLoggerFactory.getInstance(TrafficControl.class);
private TrafficControl() {
}

View File

@ -18,8 +18,8 @@ package io.netty.test.udt.util;
import com.barchart.udt.SocketUDT;
import com.barchart.udt.StatusUDT;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.netty.util.internal.InternalLogger;
import io.netty.util.internal.InternalLoggerFactory;
import java.io.File;
import java.net.InetAddress;
@ -37,7 +37,7 @@ import java.util.regex.Pattern;
*/
public final class UnitHelp {
private static final Logger log = LoggerFactory.getLogger(UnitHelp.class);
private static final InternalLogger log = InternalLoggerFactory.getInstance(UnitHelp.class);
private static final Pattern SPACES = Pattern.compile("\\s+");
/**