Skip to content

Commit e33a4fc

Browse files
committed
Refactors server log handling for improved efficiency
Changes the ArrayAppender to construct a ServerLogItem directly instead of passing individual log properties. The ServerLogProvider now accepts a ServerLogItem, extracts the log properties, adds the server ID and log ID, and then passes the log item to the log controller. This change simplifies the code and makes it more efficient by reducing the number of parameters passed and centralizing the creation of the ServerLogItem.
1 parent 0dd75d3 commit e33a4fc

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

server/src/com/mirth/connect/plugins/serverlog/ArrayAppender.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import java.io.Serializable;
1313
import java.util.Date;
14+
import java.util.HashMap;
15+
import java.util.Map;
1416

1517
import org.apache.logging.log4j.core.Layout;
1618
import org.apache.logging.log4j.core.LogEvent;
@@ -69,6 +71,17 @@ public void append(LogEvent logEvent) {
6971
throwableInformation = logText.toString();
7072
}
7173

72-
serverLogProvider.newServerLogReceived(channelId, channelName, level, date, threadName, category, lineNumber, message, throwableInformation);
74+
Map<String, Object> properties = new HashMap<>();
75+
properties.put("channelId", channelId);
76+
properties.put("channelName", channelName);
77+
properties.put("level", level);
78+
properties.put("date", date);
79+
properties.put("threadName", threadName);
80+
properties.put("category", category);
81+
properties.put("lineNumber", lineNumber);
82+
properties.put("message", message);
83+
properties.put("throwableInformation", throwableInformation);
84+
85+
serverLogProvider.newServerLogReceived(new ServerLogItem(properties));
7386
}
7487
}

server/src/com/mirth/connect/plugins/serverlog/ServerLogProvider.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,12 @@ public void init(Properties properties) {
5757
initialize();
5858
}
5959

60-
public synchronized void newServerLogReceived(String channelId, String channelName, String level, Date date, String threadName, String category, String lineNumber, String message, String throwableInformation) {
60+
public synchronized void newServerLogReceived(ServerLogItem svi) {
6161
if (logController != null) {
62-
Map<String, Object> properties = new HashMap<>();
63-
properties.put("serverId", serverId);
64-
properties.put("id", logId);
65-
properties.put("channelId", channelId);
66-
properties.put("channelName", channelName);
67-
properties.put("level", level);
68-
properties.put("date", date);
69-
properties.put("threadName", threadName);
70-
properties.put("category", category);
71-
properties.put("lineNumber", lineNumber);
72-
properties.put("message", message);
73-
properties.put("throwableInformation", throwableInformation);
74-
75-
logController.addLogItem(new ServerLogItem(properties));
62+
svi.getContext().put("serverId", serverId);
63+
svi.getContext().put("id", logId);
64+
65+
logController.addLogItem(svi);
7666
logId++;
7767
}
7868
}

0 commit comments

Comments
 (0)