aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/helper
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-08-01 23:09:20 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-08-01 23:09:20 -0700
commit18eea3995305cab6dab641f7d3dfd11b9a5433be (patch)
tree53d17ad5ed2cbeea5d2837adc2b24c679e3ae870 /src/main/java/org/traccar/helper
parentc733bc9f91e55df204d1626f6a2f88183184b041 (diff)
downloadtraccar-server-18eea3995305cab6dab641f7d3dfd11b9a5433be.tar.gz
traccar-server-18eea3995305cab6dab641f7d3dfd11b9a5433be.tar.bz2
traccar-server-18eea3995305cab6dab641f7d3dfd11b9a5433be.zip
Update reports API and add logging
Diffstat (limited to 'src/main/java/org/traccar/helper')
-rw-r--r--src/main/java/org/traccar/helper/LogAction.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/helper/LogAction.java b/src/main/java/org/traccar/helper/LogAction.java
index 16d55ec60..d16b25483 100644
--- a/src/main/java/org/traccar/helper/LogAction.java
+++ b/src/main/java/org/traccar/helper/LogAction.java
@@ -17,6 +17,10 @@
package org.traccar.helper;
import java.beans.Introspector;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,6 +50,7 @@ public final class LogAction {
private static final String PATTERN_LOGIN = "user: %d, action: %s";
private static final String PATTERN_LOGIN_FAILED = "login failed from: %s";
private static final String PATTERN_DEVICE_ACCUMULATORS = "user: %d, action: %s, deviceId: %d";
+ private static final String PATTERN_REPORT = "user: %d, report: %s, from: %s, to: %s, devices: %s, groups: %s";
public static void create(long userId, BaseModel object) {
logObjectAction(ACTION_CREATE, userId, object.getClass(), object.getId());
@@ -92,8 +97,8 @@ public final class LogAction {
PATTERN_OBJECT, userId, action, Introspector.decapitalize(clazz.getSimpleName()), objectId));
}
- private static void logLinkAction(String action, long userId,
- Class<?> owner, long ownerId, Class<?> property, long propertyId) {
+ private static void logLinkAction(
+ String action, long userId, Class<?> owner, long ownerId, Class<?> property, long propertyId) {
LOGGER.info(String.format(
PATTERN_LINK, userId, action,
Introspector.decapitalize(owner.getSimpleName()), ownerId,
@@ -104,4 +109,13 @@ public final class LogAction {
LOGGER.info(String.format(PATTERN_LOGIN, userId, action));
}
+ public static void logReport(
+ long userId, String report, Date from, Date to, List<Long> deviceIds, List<Long> groupIds) {
+ DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+ LOGGER.info(String.format(
+ PATTERN_REPORT, userId, report,
+ dateFormat.format(from), dateFormat.format(to),
+ deviceIds.toString(), groupIds.toString()));
+ }
+
}