| Method from org.apache.log4j.gui.TextPaneAppender Detail: |
public void append(LoggingEvent event) {
String text = this.layout.format(event);
String trace="";
// 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," ");
}
trace = sw.toString();
sw.getBuffer().delete(0,sw.getBuffer().length());
}
try {
if (fancy) {
textpane.setEditable(true);
textpane.insertIcon((ImageIcon)icons.get(event.priority));
textpane.setEditable(false);
}
doc.insertString(doc.getLength(),text+trace,
(MutableAttributeSet)attributes.get(event.priority));
}
catch (BadLocationException badex) {
System.err.println(badex);
}
textpane.setCaretPosition(doc.getLength());
}
|
public void close() {
}
|
public String getColorBackground() {
return colorToString(textpane.getBackground());
}
|
public String getColorDebug() {
return getColor(Priority.DEBUG);
}
|
public String getColorEmerg() {
return getColor(Priority.FATAL);
}
|
public String getColorError() {
return getColor(Priority.ERROR);
}
|
public String getColorInfo() {
return getColor(Priority.INFO);
}
|
public String getColorWarn() {
return getColor(Priority.WARN);
}
|
public boolean getFancy() {
return fancy;
}
|
public String getFontName() {
AttributeSet attrSet = (AttributeSet) attributes.get(Priority.INFO);
return StyleConstants.getFontFamily(attrSet);
}
|
public int getFontSize() {
AttributeSet attrSet = (AttributeSet) attributes.get(Priority.INFO);
return StyleConstants.getFontSize(attrSet);
}
|
public String getLabel() {
return label;
}
|
public JTextPane getTextPane() {
return textpane;
}
|
public static Image loadIcon(String path) {
Image img = null;
try {
URL url = ClassLoader.getSystemResource(path);
img = (Image) (Toolkit.getDefaultToolkit()).getImage(url);
} catch (Exception e) {
System.out.println("Exception occured: " + e.getMessage() +
" - " + e );
}
return (img);
}
|
public boolean requiresLayout() {
return true;
}
|
public void setColorBackground(String color) {
textpane.setBackground(parseColor(color));
}
|
public void setColorDebug(String color) {
setColor(Priority.DEBUG, color);
}
|
public void setColorEmerg(String color) {
setColor(Priority.FATAL, color);
}
|
public void setColorError(String color) {
setColor(Priority.ERROR, color);
}
|
public void setColorInfo(String color) {
setColor(Priority.INFO, color);
}
|
public void setColorWarn(String color) {
setColor(Priority.WARN, color);
}
|
public void setFancy(boolean fancy) {
this.fancy = fancy;
}
|
public void setFontName(String name) {
Enumeration e = attributes.elements();
while (e.hasMoreElements()) {
StyleConstants.setFontFamily((MutableAttributeSet)e.nextElement(),name);
}
return;
}
|
public void setFontSize(int size) {
Enumeration e = attributes.elements();
while (e.hasMoreElements()) {
StyleConstants.setFontSize((MutableAttributeSet)e.nextElement(),size);
}
return;
}
|
public void setLabel(String label) {
this.label = label;
}
|
public void setLayout(Layout layout) {
this.layout=layout;
}
|
public void setName(String name) {
this.name = name;
}
|
public void setTextPane(JTextPane textpane) {
this.textpane=textpane;
textpane.setEditable(false);
textpane.setBackground(Color.lightGray);
this.doc=textpane.getStyledDocument();
}
|