aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-11-09 10:58:05 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-11-09 10:58:05 +1300
commit3391586058e1b0cdb0c9245ed353f592436faa53 (patch)
tree01f5a5cd507ed3a91b8ba1c6a2c1afaf67928ea7 /src
parent9ec7166889b9b0492a18a338e6dc5352743209b8 (diff)
downloadtrackermap-server-3391586058e1b0cdb0c9245ed353f592436faa53.tar.gz
trackermap-server-3391586058e1b0cdb0c9245ed353f592436faa53.tar.bz2
trackermap-server-3391586058e1b0cdb0c9245ed353f592436faa53.zip
Change log messages formatting
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/MainEventHandler.java15
-rw-r--r--src/org/traccar/database/ConnectionManager.java4
-rw-r--r--src/org/traccar/helper/Log.java4
3 files changed, 16 insertions, 7 deletions
diff --git a/src/org/traccar/MainEventHandler.java b/src/org/traccar/MainEventHandler.java
index 48bfb3fc9..c6ad1467b 100644
--- a/src/org/traccar/MainEventHandler.java
+++ b/src/org/traccar/MainEventHandler.java
@@ -26,6 +26,10 @@ import org.jboss.netty.handler.timeout.IdleStateEvent;
import org.traccar.helper.Log;
import org.traccar.model.Position;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
public class MainEventHandler extends IdleStateAwareChannelHandler {
@Override
@@ -39,11 +43,12 @@ public class MainEventHandler extends IdleStateAwareChannelHandler {
StringBuilder s = new StringBuilder();
s.append(formatChannel(e.getChannel())).append(" ");
s.append("id: ").append(position.getDeviceId()).append(", ");
- s.append("time: ").append(position.getFixTime()).append(", ");
- s.append("lat: ").append(position.getLatitude()).append(", ");
- s.append("lon: ").append(position.getLongitude()).append(", ");
- s.append("speed: ").append(position.getSpeed()).append(", ");
- s.append("course: ").append(position.getCourse());
+ s.append("time: ").append(
+ new SimpleDateFormat(Log.DATE_FORMAT).format(position.getFixTime())).append(", ");
+ s.append("lat: ").append(String.format("%.5f", position.getLatitude())).append(", ");
+ s.append("lon: ").append(String.format("%.5f", position.getLongitude())).append(", ");
+ s.append("speed: ").append(String.format("%.1f", position.getSpeed())).append(", ");
+ s.append("course: ").append(String.format("%.1f", position.getCourse()));
Log.info(s.toString());
Context.getConnectionManager().updatePosition(position);
diff --git a/src/org/traccar/database/ConnectionManager.java b/src/org/traccar/database/ConnectionManager.java
index 8ef171673..6d1266132 100644
--- a/src/org/traccar/database/ConnectionManager.java
+++ b/src/org/traccar/database/ConnectionManager.java
@@ -17,6 +17,7 @@ package org.traccar.database;
import java.net.SocketAddress;
import java.sql.SQLException;
+import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
@@ -69,7 +70,8 @@ public class ConnectionManager {
public synchronized void updateDevice(long deviceId, String status, Date time) {
// TODO update cache and call listener
- Log.debug(deviceId + " " + status + " " + time);
+ Log.debug(deviceId + " " + status + " "
+ + new SimpleDateFormat(Log.DATE_FORMAT).format(time));
}
public synchronized void updatePosition(Position position) {
diff --git a/src/org/traccar/helper/Log.java b/src/org/traccar/helper/Log.java
index 0e55a5445..2b747734e 100644
--- a/src/org/traccar/helper/Log.java
+++ b/src/org/traccar/helper/Log.java
@@ -40,6 +40,8 @@ public final class Log {
private Log() {
}
+ public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
+
private static final String LOGGER_NAME = "traccar";
private static final String STACK_PACKAGE = "org.traccar";
@@ -49,7 +51,7 @@ public final class Log {
public static void setupLogger(Config config) throws IOException {
- Layout layout = new PatternLayout("%d{yyyy-MM-dd HH:mm:ss} %5p: %m%n");
+ Layout layout = new PatternLayout("%d{" + DATE_FORMAT + "} %5p: %m%n");
Appender appender = new DailyRollingFileAppender(
layout, config.getString("logger.file"), "'.'yyyyMMdd");