Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

package com.mirth.connect.plugins.serverlog;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.*;

import javax.swing.JComponent;

Expand All @@ -26,7 +24,9 @@
public class ServerLogClient extends DashboardTabPlugin {
private ServerLogPanel serverLogPanel;
private LinkedList<ServerLogItem> serverLogs;
private static final ServerLogItem unauthorizedLog = new ServerLogItem("You are not authorized to view the server log.");
private static final ServerLogItem unauthorizedLog = new ServerLogItem(new HashMap<String, Object>(){{
put("message", "You are not authorized to view the server log.");
}});
private int currentServerLogSize;
private boolean receivedNewLogs;
private Long lastLogId;
Expand Down
17 changes: 10 additions & 7 deletions client/src/com/mirth/connect/plugins/serverlog/ServerLogPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
public class ServerLogPanel extends javax.swing.JPanel {

private static final String ID_COLUMN_HEADER = "Id";
private static final String CHANNEL_COLUMN_HEADER = "Channel";
private static final String LOG_INFO_COLUMN_HEADER = "Log Information";
private JPopupMenu rightclickPopup;
private static final int PAUSED = 0;
Expand Down Expand Up @@ -112,7 +113,7 @@ public void mouseClicked(java.awt.event.MouseEvent evt) {
if (evt.getClickCount() >= 2) {
// synchronizing this to prevent ArrayIndexOutOfBoundsException since the server log table is constantly being redrawn.
synchronized (this) {
new ViewServerLogContentDialog(parent, String.valueOf(logTable.getModel().getValueAt(logTable.convertRowIndexToModel(logTable.getSelectedRow()), 1)));
new ViewServerLogContentDialog(parent, String.valueOf(logTable.getModel().getValueAt(logTable.convertRowIndexToModel(logTable.getSelectedRow()), 2)));
}
}
}
Expand Down Expand Up @@ -185,24 +186,26 @@ public synchronized void updateTable(LinkedList<ServerLogItem> serverLogs) {

for (ServerLogItem item : serverLogs) {
if (serverId == null || serverId.equals(item.getServerId())) {
dataList.add(new Object[] { item.getId(), item });
dataList.add(new Object[] { item.getId(), item.getChannelName(), item });
}
}

tableData = dataList.toArray(new Object[dataList.size()][]);
} else {
tableData = new Object[0][2];
tableData = new Object[0][3];
}

if (logTable != null) {
RefreshTableModel model = (RefreshTableModel) logTable.getModel();
model.refreshDataVector(tableData);
} else {
logTable = new MirthTable();
logTable.setModel(new RefreshTableModel(tableData, new String[] { ID_COLUMN_HEADER,
LOG_INFO_COLUMN_HEADER }) {

boolean[] canEdit = new boolean[] { false, false };
logTable.setModel(new RefreshTableModel(tableData, new String[] {
ID_COLUMN_HEADER,
CHANNEL_COLUMN_HEADER,
LOG_INFO_COLUMN_HEADER
}) {
boolean[] canEdit = new boolean[] { false, false, false };

public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit[columnIndex];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.logging.log4j.CloseableThreadContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.ThreadContext;

import com.mirth.connect.donkey.model.DonkeyException;
import com.mirth.connect.donkey.model.channel.DebugOptions;
Expand Down Expand Up @@ -1257,7 +1259,10 @@ protected DispatchResult dispatchRawMessage(RawMessage rawMessage, boolean batch
boolean lockAcquired = false;
Long persistedMessageId = null;

try {
try (CloseableThreadContext.Instance ctc = CloseableThreadContext
.put("channelId", channelId)
.put("channelName", name)
) {
synchronized (dispatchThreads) {
if (!shuttingDown) {
dispatchThreads.add(currentThread);
Expand Down Expand Up @@ -1933,7 +1938,10 @@ public void processUnfinishedMessages() throws Exception {

@Override
public void run() {
try {
try (CloseableThreadContext.Instance ctc = CloseableThreadContext
.put("channelId", channelId)
.put("channelName", name)
) {
do {
processSourceQueue(Constants.SOURCE_QUEUE_POLL_TIMEOUT_MILLIS);
} while (isActive() && !stopSourceQueue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
import java.util.concurrent.Callable;

import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.CloseableThreadContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.ThreadContext;

import com.mirth.connect.donkey.model.message.ConnectorMessage;
import com.mirth.connect.donkey.model.message.ContentType;
Expand Down Expand Up @@ -61,7 +63,19 @@ public List<ConnectorMessage> call() throws InterruptedException {
String originalThreadName = Thread.currentThread().getName();
try {
Thread.currentThread().setName(name + " < " + originalThreadName);
return doCall();
String channelId = chainProvider.getChannelId();
String channelName = null;

if (!chainProvider.getDestinationConnectors().isEmpty()) {
channelName = chainProvider.getDestinationConnectors().values().iterator().next().getChannel().getName();
}

try (CloseableThreadContext.Instance ctc = CloseableThreadContext
.put("channelId", channelId)
.put("channelName", channelName != null ? channelName : "")
) {
return doCall();
}
} finally {
Thread.currentThread().setName(originalThreadName);
}
Expand Down Expand Up @@ -210,4 +224,4 @@ private List<ConnectorMessage> doCall() throws InterruptedException {

return messages;
}
}
}
Loading