From 11e974ace35cb79e2b1f730e57619f9220b3b890 Mon Sep 17 00:00:00 2001 From: Cruz Bishop Date: Sun, 15 Apr 2012 19:22:02 +1000 Subject: [PATCH] Fix up the last logging mishits --- .../java/io/netty/example/localtime/LocalTimeClient.java | 2 +- .../io/netty/example/uptime/UptimeClientHandler.java | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/example/src/main/java/io/netty/example/localtime/LocalTimeClient.java b/example/src/main/java/io/netty/example/localtime/LocalTimeClient.java index f922a2bcef..c061d05ca4 100644 --- a/example/src/main/java/io/netty/example/localtime/LocalTimeClient.java +++ b/example/src/main/java/io/netty/example/localtime/LocalTimeClient.java @@ -81,7 +81,7 @@ public class LocalTimeClient { Iterator i1 = cities.iterator(); Iterator 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())); } } diff --git a/example/src/main/java/io/netty/example/uptime/UptimeClientHandler.java b/example/src/main/java/io/netty/example/uptime/UptimeClientHandler.java index 096e575db6..503f69fb83 100644 --- a/example/src/main/java/io/netty/example/uptime/UptimeClientHandler.java +++ b/example/src/main/java/io/netty/example/uptime/UptimeClientHandler.java @@ -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; @@ -34,6 +36,9 @@ import io.netty.util.TimerTask; * connection attempt status. */ public class UptimeClientHandler extends SimpleChannelUpstreamHandler { + + private static final InternalLogger logger = + InternalLoggerFactory.getInstance(UptimeClientHandler.class); final ClientBootstrap bootstrap; private final Timer timer; @@ -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)); } } }