aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/helper
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-06-01 07:57:30 -0700
committerAnton Tananaev <anton@traccar.org>2024-06-01 07:57:30 -0700
commit8b46ee99757a0c0c02051bba07679a2c37be08e7 (patch)
treebe7b9acff6aad57635c6d58751713103efc4bf29 /src/main/java/org/traccar/helper
parentc21ca48b6b255cde193efb476f83b1fac5c894f2 (diff)
downloadtrackermap-server-8b46ee99757a0c0c02051bba07679a2c37be08e7.tar.gz
trackermap-server-8b46ee99757a0c0c02051bba07679a2c37be08e7.tar.bz2
trackermap-server-8b46ee99757a0c0c02051bba07679a2c37be08e7.zip
Log command actions
Diffstat (limited to 'src/main/java/org/traccar/helper')
-rw-r--r--src/main/java/org/traccar/helper/LogAction.java31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/main/java/org/traccar/helper/LogAction.java b/src/main/java/org/traccar/helper/LogAction.java
index adbe33916..3c4b69a2e 100644
--- a/src/main/java/org/traccar/helper/LogAction.java
+++ b/src/main/java/org/traccar/helper/LogAction.java
@@ -44,12 +44,15 @@ public final class LogAction {
private static final String ACTION_LOGOUT = "logout";
private static final String ACTION_ACCUMULATORS = "accumulators";
+ private static final String ACTION_COMMAND = "command";
private static final String PATTERN_OBJECT = "user: %d, action: %s, object: %s, id: %d";
private static final String PATTERN_LINK = "user: %d, action: %s, owner: %s, id: %d, property: %s, id: %d";
private static final String PATTERN_LOGIN = "user: %d, action: %s, from: %s";
private static final String PATTERN_LOGIN_FAILED = "login failed from: %s";
private static final String PATTERN_ACCUMULATORS = "user: %d, action: %s, deviceId: %d";
+ private static final String PATTERN_COMMAND_DEVICE = "user: %d, action: %s, deviceId: %d, type: %s";
+ private static final String PATTERN_COMMAND_GROUP = "user: %d, action: %s, groupId: %d, type: %s";
private static final String PATTERN_REPORT = "user: %d, %s: %s, from: %s, to: %s, devices: %s, groups: %s";
public static void create(long userId, BaseModel object) {
@@ -92,6 +95,24 @@ public final class LogAction {
PATTERN_ACCUMULATORS, userId, ACTION_ACCUMULATORS, deviceId));
}
+ public static void command(long userId, long groupId, long deviceId, String type) {
+ if (groupId > 0) {
+ LOGGER.info(String.format(PATTERN_COMMAND_GROUP, userId, ACTION_COMMAND, groupId, type));
+ } else {
+ LOGGER.info(String.format(PATTERN_COMMAND_DEVICE, userId, ACTION_COMMAND, deviceId, type));
+ }
+ }
+
+ public static void report(
+ long userId, boolean scheduled, 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, scheduled ? "scheduled" : "report", report,
+ dateFormat.format(from), dateFormat.format(to),
+ deviceIds.toString(), groupIds.toString()));
+ }
+
private static void logObjectAction(String action, long userId, Class<?> clazz, long objectId) {
LOGGER.info(String.format(
PATTERN_OBJECT, userId, action, Introspector.decapitalize(clazz.getSimpleName()), objectId));
@@ -112,14 +133,4 @@ public final class LogAction {
LOGGER.info(String.format(PATTERN_LOGIN, userId, action, remoteAddress));
}
- public static void logReport(
- long userId, boolean scheduled, 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, scheduled ? "scheduled" : "report", report,
- dateFormat.format(from), dateFormat.format(to),
- deviceIds.toString(), groupIds.toString()));
- }
-
}