TextPanelAppenderpublic class TextPanelAppender extends AppenderSkeleton
Fields Summary |
---|
org.apache.log4j.helpers.TracerPrintWriter | tp | StringWriter | sw | QuietWriter | qw | LogTextPanel | logTextPanel | LogPublishingThread | logPublisher | final String | COLOR_OPTION_FATAL | final String | COLOR_OPTION_ERROR | final String | COLOR_OPTION_WARN | final String | COLOR_OPTION_INFO | final String | COLOR_OPTION_DEBUG | final String | COLOR_OPTION_BACKGROUND | final String | FONT_NAME_OPTION | final String | FONT_SIZE_OPTION | final String | EVENT_BUFFER_SIZE_OPTION |
Constructors Summary |
---|
public TextPanelAppender(Layout layout, String name)
this.layout = layout;
this.name = name;
this.sw = new StringWriter();
this.qw = new QuietWriter(sw, errorHandler);
this.tp = new TracerPrintWriter(qw);
setLogTextPanel(new LogTextPanel());
logPublisher = new LogPublishingThread(logTextPanel, Priority.ERROR, 500);
//logPublisher = new LogPublishingThread(logTextPanel, null, 500);
|
Methods Summary |
---|
public void | append(org.apache.log4j.spi.LoggingEvent event)
String text = this.layout.format(event);
// Print Stacktrace
// Quick Hack maybe there is a better/faster way?
if (event.throwable!=null) {
event.throwable.printStackTrace(tp);
for (int i=0; i< sw.getBuffer().length(); i++) {
if (sw.getBuffer().charAt(i)=='\t")
sw.getBuffer().replace(i,i+1," ");
}
text += sw.toString();
sw.getBuffer().delete(0,sw.getBuffer().length());
}
else
if(!text.endsWith("\n"))
text += "\n";
logPublisher.publishEvent(event.priority, text);
| public void | close()
| public javax.swing.JPanel | getLogTextPanel()
return logTextPanel;
| public java.lang.String[] | getOptionStrings()
return new String[] { COLOR_OPTION_FATAL, COLOR_OPTION_ERROR,
COLOR_OPTION_WARN, COLOR_OPTION_INFO, COLOR_OPTION_DEBUG,
COLOR_OPTION_BACKGROUND, FONT_NAME_OPTION, FONT_SIZE_OPTION};
| public boolean | requiresLayout()
return true;
| protected void | setLogTextPanel(LogTextPanel logTextPanel)
this.logTextPanel = logTextPanel;
logTextPanel.setTextBackground(Color.white);
| public void | setName(java.lang.String name)
this.name = name;
| public void | setOption(java.lang.String option, java.lang.String value)
if (option.equalsIgnoreCase(COLOR_OPTION_FATAL))
logTextPanel.setTextColor(Priority.FATAL,value);
if (option.equalsIgnoreCase(COLOR_OPTION_ERROR))
logTextPanel.setTextColor(Priority.ERROR,value);
if (option.equalsIgnoreCase(COLOR_OPTION_WARN))
logTextPanel.setTextColor(Priority.WARN,value);
if (option.equalsIgnoreCase(COLOR_OPTION_INFO))
logTextPanel.setTextColor(Priority.INFO,value);
if (option.equalsIgnoreCase(COLOR_OPTION_DEBUG))
logTextPanel.setTextColor(Priority.DEBUG,value);
if (option.equalsIgnoreCase(COLOR_OPTION_BACKGROUND))
logTextPanel.setTextBackground(value);
if (option.equalsIgnoreCase(FONT_SIZE_OPTION))
logTextPanel.setTextFontSize(Integer.parseInt(value));
if (option.equalsIgnoreCase(FONT_NAME_OPTION))
logTextPanel.setTextFontName(value);
if (option.equalsIgnoreCase(EVENT_BUFFER_SIZE_OPTION))
logTextPanel.setEventBufferSize(Integer.parseInt(value));
return;
|
|