Skip to content

Commit

Permalink
fix overlapping logger output
Browse files Browse the repository at this point in the history
  • Loading branch information
GraxCode committed Jun 4, 2020
1 parent 31e42f4 commit cb49e7f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
46 changes: 24 additions & 22 deletions src/me/nov/threadtear/logging/Appender.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,31 +69,33 @@ protected void append(ILoggingEvent event) {
if (textPane == null) {
return;
}
try {
int limite = 800;
int apaga = 200;
if (textPane.getDocument().getDefaultRootElement().getElementCount() > limite) {
int end = getLineEndOffset(textPane, apaga);
replaceRange(textPane, null, 0, end);
synchronized (textPane.getDocument()) {
try {
int limite = 800;
int apaga = 200;
if (textPane.getDocument().getDefaultRootElement().getElementCount() > limite) {
int end = getLineEndOffset(textPane, apaga);
replaceRange(textPane, null, 0, end);
}

if (event.getLevel() == Level.ERROR)
textPane.getDocument().insertString(textPane.getDocument().getLength(), formattedMsg, ERROR_ATT);
else if (event.getLevel() == Level.WARN)
textPane.getDocument().insertString(textPane.getDocument().getLength(), formattedMsg, WARN_ATT);
else if (event.getLevel() == Level.INFO)
textPane.getDocument().insertString(textPane.getDocument().getLength(), formattedMsg, INFO_ATT);
else if (event.getLevel() == Level.DEBUG)
textPane.getDocument().insertString(textPane.getDocument().getLength(), formattedMsg, DEBUG_ATT);
else if (event.getLevel() == Level.TRACE)
textPane.getDocument().insertString(textPane.getDocument().getLength(), formattedMsg, TRACE_ATT);
else
textPane.getDocument().insertString(textPane.getDocument().getLength(), formattedMsg, RESTO_ATT);

} catch (BadLocationException e) {
}

if (event.getLevel() == Level.ERROR)
textPane.getDocument().insertString(textPane.getDocument().getLength(), formattedMsg, ERROR_ATT);
else if (event.getLevel() == Level.WARN)
textPane.getDocument().insertString(textPane.getDocument().getLength(), formattedMsg, WARN_ATT);
else if (event.getLevel() == Level.INFO)
textPane.getDocument().insertString(textPane.getDocument().getLength(), formattedMsg, INFO_ATT);
else if (event.getLevel() == Level.DEBUG)
textPane.getDocument().insertString(textPane.getDocument().getLength(), formattedMsg, DEBUG_ATT);
else if (event.getLevel() == Level.TRACE)
textPane.getDocument().insertString(textPane.getDocument().getLength(), formattedMsg, TRACE_ATT);
else
textPane.getDocument().insertString(textPane.getDocument().getLength(), formattedMsg, RESTO_ATT);

} catch (BadLocationException e) {
textPane.setCaretPosition(textPane.getDocument().getLength());
}

textPane.setCaretPosition(textPane.getDocument().getLength());
});
}

Expand Down
4 changes: 4 additions & 0 deletions src/me/nov/threadtear/vm/VM.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private byte[] convert(String name, ClassNode node, boolean noInitialization, Bi
if (dummyLoading) {
ClassNode dummy = new ClassNode();
dummy.name = name.replace('.', '/');
dummy.superName = "java/lang/Object";
dummy.version = 52;
return Conversion.toBytecode0(dummy);
}
Expand Down Expand Up @@ -119,6 +120,9 @@ private int fixAccess(int access) {
if (Access.isInterface(access)) {
newAccess |= ACC_INTERFACE;
}
if (Access.isEnum(access)) {
newAccess |= ACC_ENUM;
}
if (Access.isAbstract(access)) {
newAccess |= ACC_ABSTRACT;
}
Expand Down

0 comments on commit cb49e7f

Please sign in to comment.