Skip to content

Commit

Permalink
moved copying of logevents to GuiAppender
Browse files Browse the repository at this point in the history
  • Loading branch information
r0light committed Mar 27, 2019
1 parent 577de6a commit 7e20650
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/JabRefGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private void openWindow(Stage mainStage) {
String message = Localization.lang("Error opening file '%0'.", pr.getFile().get().getName()) + "\n"
+ pr.getErrorMessage();

JabRefGUI.mainFrame.getDialogService().showErrorDialogAndWait(Localization.lang("Error opening file"), message);
dialogService.showErrorDialogAndWait(Localization.lang("Error opening file"), message);

}

Expand Down
6 changes: 5 additions & 1 deletion src/main/java/org/jabref/gui/logging/GuiAppender.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
import org.apache.logging.log4j.core.config.plugins.PluginElement;
import org.apache.logging.log4j.core.config.plugins.PluginFactory;
import org.apache.logging.log4j.core.impl.MutableLogEvent;
import org.apache.logging.log4j.core.layout.PatternLayout;

@Plugin(name = "GuiAppender", category = "Core", elementType = "appender", printObject = true)
Expand Down Expand Up @@ -44,6 +45,9 @@ public static GuiAppender createAppender(@PluginAttribute("name") String name,
*/
@Override
public void append(LogEvent event) {
DefaultTaskExecutor.runInJavaFXThread(() -> LogMessages.getInstance().add(event));
// We need to make a copy as instances of LogEvent are reused by log4j
MutableLogEvent copy = new MutableLogEvent();
copy.initFrom(event);
DefaultTaskExecutor.runInJavaFXThread(() -> LogMessages.getInstance().add(copy));
}
}
6 changes: 1 addition & 5 deletions src/main/java/org/jabref/logic/logging/LogMessages.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import javafx.collections.ObservableList;

import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.impl.MutableLogEvent;

/**
* This class is used for storing and archiving all message output of JabRef as log events.
Expand All @@ -28,10 +27,7 @@ public ObservableList<LogEvent> getMessages() {
}

public void add(LogEvent event) {
// We need to make a copy as instances of LogEvent are reused by log4j
MutableLogEvent copy = new MutableLogEvent();
copy.initFrom(event);
messages.add(copy);
messages.add(event);
}

public void clear() {
Expand Down

0 comments on commit 7e20650

Please sign in to comment.