diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-10-21 13:59:10 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-10-21 13:59:10 +1300 |
commit | 37a594b4ac0297988b2d2d073bfaee5700df043e (patch) | |
tree | 9796106be152dc854307c6e4d22713c2527fdb4b | |
parent | 5391eacb835bf34e4d085fb7b1a385dbd9bdcd5e (diff) | |
download | trackermap-server-37a594b4ac0297988b2d2d073bfaee5700df043e.tar.gz trackermap-server-37a594b4ac0297988b2d2d073bfaee5700df043e.tar.bz2 trackermap-server-37a594b4ac0297988b2d2d073bfaee5700df043e.zip |
Log all commands to devices
-rw-r--r-- | src/org/traccar/BaseProtocolEncoder.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/org/traccar/BaseProtocolEncoder.java b/src/org/traccar/BaseProtocolEncoder.java index 296ee2d4b..d53607e68 100644 --- a/src/org/traccar/BaseProtocolEncoder.java +++ b/src/org/traccar/BaseProtocolEncoder.java @@ -18,7 +18,9 @@ package org.traccar; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; +import org.traccar.helper.Log; import org.traccar.model.Command; +import org.traccar.model.Position; public abstract class BaseProtocolEncoder extends OneToOneEncoder { @@ -30,7 +32,22 @@ public abstract class BaseProtocolEncoder extends OneToOneEncoder { protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { if (msg instanceof Command) { - return encodeCommand((Command) msg); + Command command = (Command) msg; + Object encodedCommand = encodeCommand(command); + + // Log command + StringBuilder s = new StringBuilder(); + s.append(String.format("[%08X] ", channel.getId())); + s.append("command type: ").append(command.getType()).append(", "); + s.append("id : ").append(command.getDeviceId()).append(" "); + if (encodedCommand != null) { + s.append("sent"); + } else { + s.append("not sent"); + } + Log.info(s.toString()); + + return encodedCommand; } return msg; |