Fix up the last logging mishits

This commit is contained in:
Cruz Bishop 2012-04-15 19:22:02 +10:00
parent a682b018b2
commit 11e974ace3
2 changed files with 8 additions and 3 deletions

View File

@ -81,7 +81,7 @@ public class LocalTimeClient {
Iterator<String> i1 = cities.iterator(); Iterator<String> i1 = cities.iterator();
Iterator<String> i2 = response.iterator(); Iterator<String> i2 = response.iterator();
while (i1.hasNext()) { while (i1.hasNext()) {
System.out.format("%28s: %s%n", i1.next(), i2.next()); logger.info(String.format("%28s: %s%n", i1.next(), i2.next()));
} }
} }

View File

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