aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/MainEventHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/MainEventHandler.java')
-rw-r--r--src/org/traccar/MainEventHandler.java42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/org/traccar/MainEventHandler.java b/src/org/traccar/MainEventHandler.java
index d4e1ff860..c905508e0 100644
--- a/src/org/traccar/MainEventHandler.java
+++ b/src/org/traccar/MainEventHandler.java
@@ -35,18 +35,19 @@ import java.util.Set;
public class MainEventHandler extends ChannelInboundHandlerAdapter {
private static final Logger LOGGER = LoggerFactory.getLogger(GeocoderHandler.class);
- private static final String DEFAULT_LOGGER_EVENTS = "time,position,speed,course,accuracy,result";
+
+ private static final String DEFAULT_LOGGER_ATTRIBUTES = "time,position,speed,course,accuracy,result";
private final Set<String> connectionlessProtocols = new HashSet<>();
- private final Set<String> logEvents;
+ private final Set<String> logAttributes = new LinkedHashSet<>();
public MainEventHandler() {
String connectionlessProtocolList = Context.getConfig().getString("status.ignoreOffline");
if (connectionlessProtocolList != null) {
connectionlessProtocols.addAll(Arrays.asList(connectionlessProtocolList.split(",")));
}
- logEvents = new LinkedHashSet<>(Arrays.asList(
- Context.getConfig().getString("logger.events", DEFAULT_LOGGER_EVENTS).split(",")));
+ logAttributes.addAll(Arrays.asList(
+ Context.getConfig().getString("logger.attributes", DEFAULT_LOGGER_ATTRIBUTES).split(",")));
}
@Override
@@ -62,51 +63,50 @@ public class MainEventHandler extends ChannelInboundHandlerAdapter {
String uniqueId = Context.getIdentityManager().getById(position.getDeviceId()).getUniqueId();
- // Log position
- StringBuilder s = new StringBuilder();
- s.append(formatChannel(ctx.channel())).append(" ");
- s.append("id: ").append(uniqueId);
- for (String event : logEvents) {
- switch (event) {
+ StringBuilder builder = new StringBuilder();
+ builder.append(formatChannel(ctx.channel())).append(" ");
+ builder.append("id: ").append(uniqueId);
+ for (String attribute : logAttributes) {
+ switch (attribute) {
case "time":
- s.append(", time: ").append(DateUtil.formatDate(position.getFixTime(), false));
+ builder.append(", time: ").append(DateUtil.formatDate(position.getFixTime(), false));
break;
case "position":
- s.append(", lat: ").append(String.format("%.5f", position.getLatitude()));
- s.append(", lon: ").append(String.format("%.5f", position.getLongitude()));
+ builder.append(", lat: ").append(String.format("%.5f", position.getLatitude()));
+ builder.append(", lon: ").append(String.format("%.5f", position.getLongitude()));
break;
case "speed":
if (position.getSpeed() > 0) {
- s.append(", speed: ").append(String.format("%.1f", position.getSpeed()));
+ builder.append(", speed: ").append(String.format("%.1f", position.getSpeed()));
}
break;
case "course":
- s.append(", course: ").append(String.format("%.1f", position.getCourse()));
+ builder.append(", course: ").append(String.format("%.1f", position.getCourse()));
break;
case "accuracy":
if (position.getAccuracy() > 0) {
- s.append(", accuracy: ").append(String.format("%.1f", position.getAccuracy()));
+ builder.append(", accuracy: ").append(String.format("%.1f", position.getAccuracy()));
}
break;
case "outdated":
if (position.getOutdated()) {
- s.append(", outdated");
+ builder.append(", outdated");
}
break;
case "invalid":
if (!position.getValid()) {
- s.append(", invalid");
+ builder.append(", invalid");
}
break;
default:
- Object value = position.getAttributes().get(event);
+ Object value = position.getAttributes().get(attribute);
if (value != null) {
- s.append(", ").append(event).append(": ").append(value);
+ builder.append(", ").append(attribute).append(": ").append(value);
}
break;
}
}
- LOGGER.info(s.toString());
+ LOGGER.info(builder.toString());
Context.getStatisticsManager().registerMessageStored(position.getDeviceId());
}