-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc924e0
commit 3c4764a
Showing
8 changed files
with
70 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,38 @@ | ||
package org.jabref.gui.logging; | ||
|
||
import java.util.Locale; | ||
import java.util.Collection; | ||
import java.util.EnumSet; | ||
import java.util.Map; | ||
|
||
import org.tinylog.Level; | ||
import org.tinylog.format.AdvancedMessageFormatter; | ||
import org.tinylog.format.MessageFormatter; | ||
import org.tinylog.provider.ContextProvider; | ||
import org.tinylog.provider.LoggingProvider; | ||
import org.tinylog.provider.NopContextProvider; | ||
import org.jabref.gui.util.DefaultTaskExecutor; | ||
import org.jabref.logic.logging.LogMessages; | ||
|
||
public class GuiAppender implements LoggingProvider { | ||
import org.tinylog.core.LogEntry; | ||
import org.tinylog.core.LogEntryValue; | ||
import org.tinylog.writers.AbstractFormatPatternWriter; | ||
|
||
@Override | ||
public ContextProvider getContextProvider() { | ||
return new NopContextProvider(); | ||
} | ||
|
||
@Override | ||
public Level getMinimumLevel() { | ||
return Level.INFO; | ||
} | ||
public class GuiAppender extends AbstractFormatPatternWriter { | ||
|
||
@Override | ||
public Level getMinimumLevel(String tag) { | ||
return Level.INFO; | ||
public GuiAppender(final Map<String, String> properties) { | ||
super(properties); | ||
} | ||
|
||
@Override | ||
public boolean isEnabled(int depth, String tag, Level level) { | ||
return level.ordinal() >= Level.INFO.ordinal(); | ||
public Collection<LogEntryValue> getRequiredLogEntryValues() { | ||
return EnumSet.allOf(LogEntryValue.class); | ||
} | ||
|
||
@Override | ||
public void shutdown() { | ||
// Nothing to do | ||
} | ||
|
||
private void log(Throwable exception, String message, Object[] arguments) { | ||
StringBuilder builder = new StringBuilder(); | ||
if (message != null) { | ||
builder.append(new AdvancedMessageFormatter(Locale.ENGLISH, true).format(message, arguments)); | ||
} | ||
if (exception != null) { | ||
if (builder.length() > 0) { | ||
builder.append(": "); | ||
} | ||
builder.append(exception); | ||
} | ||
System.out.println(builder); | ||
public void write(LogEntry logEntry) throws Exception { | ||
DefaultTaskExecutor.runInJavaFXThread(() -> LogMessages.getInstance().add(logEntry)); | ||
} | ||
|
||
@Override | ||
public void log(int depth, String tag, Level level, Throwable exception, MessageFormatter formatter, Object obj, Object... arguments) { | ||
// TODO Auto-generated method stub | ||
|
||
public void flush() throws Exception { | ||
} | ||
|
||
@Override | ||
public void log(String loggerClassName, String tag, Level level, Throwable exception, MessageFormatter formatter, Object obj, Object... arguments) { | ||
// TODO Auto-generated method stub | ||
|
||
public void close() throws Exception { | ||
} | ||
|
||
/* | ||
The log event will be forwarded to the {@link LogMessages} archive. | ||
public void append(LoggingEvent event) { | ||
// We need to make a copy as instances of LogEvent are reused by log4j | ||
DefaultTaskExecutor.runInJavaFXThread(() -> LogMessages.getInstance().add(copy)); | ||
} | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/main/resources/META-INF/services/org.tinylog.writers.Writer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
org.jabreg.gui.logging.ApplicationInsightsAppender | ||
org.jabref.gui.logging.GuiAppender |
This file was deleted.
Oops, something went wrong.