Methods Summary |
---|
public void | append(org.apache.log4j.spi.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()
|
private static java.lang.String | colorToString(java.awt.Color c)
// alpha component emitted only if not default (255)
String res = ""+c.getRed()+","+c.getGreen()+","+c.getBlue();
return c.getAlpha() >= 255 ? res : res + ","+c.getAlpha();
|
private void | createAttributes()
Priority prio[] = Priority.getAllPossiblePriorities();
attributes = new Hashtable();
for (int i=0; i<prio.length;i++) {
MutableAttributeSet att = new SimpleAttributeSet();
attributes.put(prio[i], att);
StyleConstants.setFontSize(att,14);
}
StyleConstants.setForeground((MutableAttributeSet)attributes.get(Priority.ERROR),Color.red);
StyleConstants.setForeground((MutableAttributeSet)attributes.get(Priority.WARN),Color.orange);
StyleConstants.setForeground((MutableAttributeSet)attributes.get(Priority.INFO),Color.gray);
StyleConstants.setForeground((MutableAttributeSet)attributes.get(Priority.DEBUG),Color.black);
|
private void | createIcons()
Priority prio[] = Priority.getAllPossiblePriorities();
icons = new Hashtable();
for (int i=0; i<prio.length;i++) {
if (prio[i].equals(Priority.FATAL))
icons.put(prio[i],new ImageIcon(loadIcon("icons/RedFlag.gif")));
if (prio[i].equals(Priority.ERROR))
icons.put(prio[i],new ImageIcon(loadIcon("icons/RedFlag.gif")));
if (prio[i].equals(Priority.WARN))
icons.put(prio[i],new ImageIcon(loadIcon("icons/BlueFlag.gif")));
if (prio[i].equals(Priority.INFO))
icons.put(prio[i],new ImageIcon(loadIcon("icons/GreenFlag.gif")));
if (prio[i].equals(Priority.DEBUG))
icons.put(prio[i],new ImageIcon(loadIcon("icons/GreenFlag.gif")));
}
|
private java.lang.String | getColor(org.apache.log4j.Priority p)
Color c = StyleConstants.getForeground(
(MutableAttributeSet)attributes.get(p));
return c == null ? null : colorToString(c);
|
public java.lang.String | getColorBackground()
return colorToString(textpane.getBackground());
|
public java.lang.String | getColorDebug()
return getColor(Priority.DEBUG);
|
public java.lang.String | getColorEmerg()
return getColor(Priority.FATAL);
|
public java.lang.String | getColorError()
return getColor(Priority.ERROR);
|
public java.lang.String | getColorInfo()
return getColor(Priority.INFO);
|
public java.lang.String | getColorWarn()
return getColor(Priority.WARN);
|
public boolean | getFancy()
return fancy;
|
public java.lang.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 java.lang.String | getLabel()
return label;
|
public javax.swing.JTextPane | getTextPane()
return textpane;
|
public static java.awt.Image | loadIcon(java.lang.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);
|
private static java.awt.Color | parseColor(java.lang.String v)
StringTokenizer st = new StringTokenizer(v,",");
int val[] = {255,255,255,255};
int i=0;
while (st.hasMoreTokens()) {
val[i]=Integer.parseInt(st.nextToken());
i++;
}
return new Color(val[0],val[1],val[2],val[3]);
|
public boolean | requiresLayout()
return true;
|
private void | setColor(org.apache.log4j.Priority p, java.lang.String v)
StyleConstants.setForeground(
(MutableAttributeSet)attributes.get(p),parseColor(v));
|
public void | setColorBackground(java.lang.String color)
textpane.setBackground(parseColor(color));
|
public void | setColorDebug(java.lang.String color)
setColor(Priority.DEBUG, color);
|
public void | setColorEmerg(java.lang.String color)
setColor(Priority.FATAL, color);
|
public void | setColorError(java.lang.String color)
setColor(Priority.ERROR, color);
|
public void | setColorInfo(java.lang.String color)
setColor(Priority.INFO, color);
|
public void | setColorWarn(java.lang.String color)
setColor(Priority.WARN, color);
|
public void | setFancy(boolean fancy)
this.fancy = fancy;
|
public void | setFontName(java.lang.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(java.lang.String label)
this.label = label;
|
public void | setLayout(org.apache.log4j.Layout layout)
this.layout=layout;
|
public void | setName(java.lang.String name)
this.name = name;
|
public void | setTextPane(javax.swing.JTextPane textpane)
this.textpane=textpane;
textpane.setEditable(false);
textpane.setBackground(Color.lightGray);
this.doc=textpane.getStyledDocument();
|