diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-09-14 14:33:49 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-09-14 14:33:49 +1200 |
commit | b10824bb5769c4abb93e3451673b88efdfb9d467 (patch) | |
tree | c4d04ed2f19d5758a75b702467dbc051c5d0511c /src/org/traccar/MainEventHandler.java | |
parent | e331573c0df7467fd36ae3eba3c259ed9b1d9253 (diff) | |
download | trackermap-server-b10824bb5769c4abb93e3451673b88efdfb9d467.tar.gz trackermap-server-b10824bb5769c4abb93e3451673b88efdfb9d467.tar.bz2 trackermap-server-b10824bb5769c4abb93e3451673b88efdfb9d467.zip |
Log using slf4j and java logging
Diffstat (limited to 'src/org/traccar/MainEventHandler.java')
-rw-r--r-- | src/org/traccar/MainEventHandler.java | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/org/traccar/MainEventHandler.java b/src/org/traccar/MainEventHandler.java index 49694aaff..b24edf28e 100644 --- a/src/org/traccar/MainEventHandler.java +++ b/src/org/traccar/MainEventHandler.java @@ -20,7 +20,8 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.socket.DatagramChannel; import io.netty.handler.timeout.IdleStateEvent; -import org.traccar.helper.Log; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.traccar.model.Position; import java.sql.SQLException; @@ -31,6 +32,8 @@ import java.util.Set; public class MainEventHandler extends ChannelInboundHandlerAdapter { + private static final Logger LOGGER = LoggerFactory.getLogger(GeocoderHandler.class); + private final Set<String> connectionlessProtocols = new HashSet<>(); public MainEventHandler() { @@ -48,7 +51,7 @@ public class MainEventHandler extends ChannelInboundHandlerAdapter { try { Context.getDeviceManager().updateLatestPosition(position); } catch (SQLException error) { - Log.warning(error); + LOGGER.warn(null, error); } String uniqueId = Context.getIdentityManager().getById(position.getDeviceId()).getUniqueId(); @@ -58,7 +61,7 @@ public class MainEventHandler extends ChannelInboundHandlerAdapter { s.append(formatChannel(ctx.channel())).append(" "); s.append("id: ").append(uniqueId); s.append(", time: ").append( - new SimpleDateFormat(Log.DATE_FORMAT).format(position.getFixTime())); + new SimpleDateFormat(Context.DATE_FORMAT).format(position.getFixTime())); s.append(", lat: ").append(String.format("%.5f", position.getLatitude())); s.append(", lon: ").append(String.format("%.5f", position.getLongitude())); if (position.getSpeed() > 0) { @@ -72,7 +75,7 @@ public class MainEventHandler extends ChannelInboundHandlerAdapter { if (cmdResult != null) { s.append(", result: ").append(cmdResult); } - Log.info(s.toString()); + LOGGER.info(s.toString()); Context.getStatisticsManager().registerMessageStored(position.getDeviceId()); } @@ -84,12 +87,12 @@ public class MainEventHandler extends ChannelInboundHandlerAdapter { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { - Log.info(formatChannel(ctx.channel()) + " connected"); + LOGGER.info(formatChannel(ctx.channel()) + " connected"); } @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { - Log.info(formatChannel(ctx.channel()) + " disconnected"); + LOGGER.info(formatChannel(ctx.channel()) + " disconnected"); closeChannel(ctx.channel()); BaseProtocolDecoder protocolDecoder = (BaseProtocolDecoder) ctx.pipeline().get("objectDecoder"); @@ -101,14 +104,14 @@ public class MainEventHandler extends ChannelInboundHandlerAdapter { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - Log.warning(formatChannel(ctx.channel()) + " error", cause); + LOGGER.warn(formatChannel(ctx.channel()) + " error", cause); closeChannel(ctx.channel()); } @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof IdleStateEvent) { - Log.info(formatChannel(ctx.channel()) + " timed out"); + LOGGER.info(formatChannel(ctx.channel()) + " timed out"); closeChannel(ctx.channel()); } } |