Ignore warnings and errors. This needs work.

Suggestion: Make it so it looks for the :[timestamp WARN/ERROR] and sets a bit to flag all subsequent lines as error/warning lines, till the next line that starts with : or matches :[timestamp INFO]
This commit is contained in:
StevenLawson 2014-08-20 21:20:01 -04:00
parent 010e673ab9
commit fd944e110c
3 changed files with 57 additions and 10 deletions

View file

@ -21,6 +21,10 @@ public class BTC_FormatHandler
private static final Pattern ISSUED_SERVER_COMMAND = Pattern.compile("^:\\[.+? INFO\\]: .+? issued server command: ");
private static final Pattern PLAYER_COMMAND = Pattern.compile("^:\\[.+? INFO\\]: \\[PLAYER_COMMAND\\] ");
private static final Pattern ERROR_MESSAGE = Pattern.compile("^:\\[.+? (!?(WARN)|(ERROR))\\]: ");
private static final Pattern EXCEPTION_MESSAGE = Pattern.compile("^[^\\[][^\\s]+: ");
private static final Pattern STACK_TRACE = Pattern.compile("^\\t");
private BTC_FormatHandler()
{
throw new AssertionError();
@ -50,30 +54,38 @@ public class BTC_FormatHandler
{
return true;
}
else if (mainPanel.getChkIgnoreErrors().isSelected() && (ERROR_MESSAGE.matcher(line).find() || STACK_TRACE.matcher(line).find() || EXCEPTION_MESSAGE.matcher(line).find()))
{
return true;
}
return false;
}
public static final Color getColor(String text)
public static final Color getColor(String line)
{
Color color = Color.BLACK;
if (CHAT_MESSAGE.matcher(text).find() || SAY_MESSAGE.matcher(text).find() || CSAY_MESSAGE.matcher(text).find())
if (CHAT_MESSAGE.matcher(line).find() || SAY_MESSAGE.matcher(line).find() || CSAY_MESSAGE.matcher(line).find())
{
color = Color.BLUE;
}
else if (ADMINSAY_MESSAGE.matcher(text).find())
else if (ADMINSAY_MESSAGE.matcher(line).find())
{
color = PURPLE;
}
else if (WORLD_EDIT.matcher(text).find())
else if (WORLD_EDIT.matcher(line).find())
{
color = Color.RED;
}
else if (PREPROCESS_COMMAND.matcher(text).find())
else if (PREPROCESS_COMMAND.matcher(line).find())
{
color = DARK_GREEN;
}
else if (ERROR_MESSAGE.matcher(line).find() || STACK_TRACE.matcher(line).find() || EXCEPTION_MESSAGE.matcher(line).find())
{
color = Color.LIGHT_GRAY;
}
return color;
}

View file

@ -299,8 +299,9 @@
<Component id="chkIgnorePlayerCommands" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="chkIgnoreServerCommands" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="chkShowChatOnly" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="chkIgnoreErrors" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace pref="79" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -313,7 +314,9 @@
<Component id="chkIgnoreServerCommands" min="-2" pref="23" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="chkShowChatOnly" min="-2" pref="23" max="-2" attributes="0"/>
<EmptySpace pref="341" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="chkIgnoreErrors" min="-2" pref="23" max="-2" attributes="0"/>
<EmptySpace pref="318" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -339,6 +342,14 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="chkShowChatOnlyActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="chkIgnoreErrors">
<Properties>
<Property name="text" type="java.lang.String" value="Ignore warnings and errors"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="chkIgnoreErrorsActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>

View file

@ -468,6 +468,7 @@ public class BTC_MainPanel extends javax.swing.JFrame
chkIgnorePlayerCommands = new javax.swing.JCheckBox();
chkIgnoreServerCommands = new javax.swing.JCheckBox();
chkShowChatOnly = new javax.swing.JCheckBox();
chkIgnoreErrors = new javax.swing.JCheckBox();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("BukkitTelnetClient");
@ -645,6 +646,15 @@ public class BTC_MainPanel extends javax.swing.JFrame
}
});
chkIgnoreErrors.setText("Ignore warnings and errors");
chkIgnoreErrors.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
chkIgnoreErrorsActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
@ -654,8 +664,9 @@ public class BTC_MainPanel extends javax.swing.JFrame
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(chkIgnorePlayerCommands)
.addComponent(chkIgnoreServerCommands)
.addComponent(chkShowChatOnly))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(chkShowChatOnly)
.addComponent(chkIgnoreErrors))
.addContainerGap(79, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -666,7 +677,9 @@ public class BTC_MainPanel extends javax.swing.JFrame
.addComponent(chkIgnoreServerCommands, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkShowChatOnly, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(341, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkIgnoreErrors, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(318, Short.MAX_VALUE))
);
jTabbedPane1.addTab("Filters", jPanel1);
@ -741,11 +754,17 @@ public class BTC_MainPanel extends javax.swing.JFrame
chkIgnoreServerCommands.setEnabled(enable);
}//GEN-LAST:event_chkShowChatOnlyActionPerformed
private void chkIgnoreErrorsActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_chkIgnoreErrorsActionPerformed
{//GEN-HEADEREND:event_chkIgnoreErrorsActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_chkIgnoreErrorsActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnConnect;
private javax.swing.JButton btnDisconnect;
private javax.swing.JButton btnSend;
private javax.swing.JCheckBox chkAutoScroll;
private javax.swing.JCheckBox chkIgnoreErrors;
private javax.swing.JCheckBox chkIgnorePlayerCommands;
private javax.swing.JCheckBox chkIgnoreServerCommands;
private javax.swing.JCheckBox chkShowChatOnly;
@ -813,4 +832,9 @@ public class BTC_MainPanel extends javax.swing.JFrame
{
return chkShowChatOnly;
}
public JCheckBox getChkIgnoreErrors()
{
return chkIgnoreErrors;
}
}