diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2012-12-18 22:31:16 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2012-12-18 22:31:16 +1300 |
commit | f72eade8742022502e69b300296c8ac1fbf35b25 (patch) | |
tree | 4ae108a169b51dbb36e2789f367dac77310ccbc3 /src/org/traccar/GenericPipelineFactory.java | |
parent | 34923934e0ee7d707aa9ffef2712942115236472 (diff) | |
download | trackermap-server-f72eade8742022502e69b300296c8ac1fbf35b25.tar.gz trackermap-server-f72eade8742022502e69b300296c8ac1fbf35b25.tar.bz2 trackermap-server-f72eade8742022502e69b300296c8ac1fbf35b25.zip |
Couple of small changes
Diffstat (limited to 'src/org/traccar/GenericPipelineFactory.java')
-rw-r--r-- | src/org/traccar/GenericPipelineFactory.java | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/org/traccar/GenericPipelineFactory.java b/src/org/traccar/GenericPipelineFactory.java index 3d20ec433..556d86e1d 100644 --- a/src/org/traccar/GenericPipelineFactory.java +++ b/src/org/traccar/GenericPipelineFactory.java @@ -17,6 +17,7 @@ package org.traccar; import java.net.InetSocketAddress; import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.*; import org.jboss.netty.handler.logging.LoggingHandler; import org.jboss.netty.handler.timeout.IdleStateHandler; @@ -63,22 +64,19 @@ public abstract class GenericPipelineFactory implements ChannelPipelineFactory { public void log(ChannelEvent e) { if (e instanceof MessageEvent) { MessageEvent event = (MessageEvent) e; - String msg = "[" + ((InetSocketAddress) e.getChannel().getLocalAddress()).getPort() + " - "; - msg += ((InetSocketAddress) event.getRemoteAddress()).getAddress().getHostAddress() + "]"; + StringBuilder msg = new StringBuilder(); + + msg.append("[").append(((InetSocketAddress) e.getChannel().getLocalAddress()).getPort()).append(" - "); + msg.append(((InetSocketAddress) event.getRemoteAddress()).getAddress().getHostAddress()).append("]"); // Append hex message if (event.getMessage() instanceof ChannelBuffer) { - ChannelBuffer buffer = (ChannelBuffer) event.getMessage(); - msg += " - (HEX: "; - for (int i = buffer.readerIndex(); i < buffer.writerIndex(); i++) { - byte b = buffer.getByte(i); - msg += HEX_CHARS.charAt((b & 0xf0) >> 4); - msg += HEX_CHARS.charAt((b & 0x0F)); - } - msg += ")"; + msg.append(" - (HEX: "); + msg.append(ChannelBuffers.hexDump((ChannelBuffer) event.getMessage())); + msg.append(")"); } - Log.fine(msg); + Log.fine(msg.toString()); } else if (e instanceof ExceptionEvent) { ExceptionEvent event = (ExceptionEvent) e; Log.warning(event.getCause().toString()); |