KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jzonic > jlo > formatter > PlainFormatter


1 package org.jzonic.jlo.formatter;
2
3 import org.jzonic.jlo.LogRecord;
4
5 import java.util.Map JavaDoc;
6 /**
7  * The SimpleFormatter is a concrete implementation of a Formatter.
8  * The format is:
9  * <pre>
10  * [target] text of the message
11  * </pre>
12  *
13  *@author Andreas Mecky
14  *@author Terry Dye
15  */

16 public class PlainFormatter extends AbstractFormatter {
17     /**
18      * Constructor for the SimpleFormatter object
19      */

20     public PlainFormatter(String JavaDoc configName) {
21         super(configName);
22     }
23     
24     
25     /**
26      *@param lr The LogRecord
27      *@return The message as string that should be logged
28      */

29     public String JavaDoc formatMessage(LogRecord lr) {
30         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
31         if (lr.getTarget() != null) {
32             sb.append("[");
33             sb.append(lr.getTarget().getName().toUpperCase());
34             sb.append("] ");
35         }
36         if (lr.getMessage() != null) {
37             sb.append(lr.getMessage());
38         }
39         if ( lr.getThrown() != null ) {
40             sb.append(":");
41             sb.append(lr.getThrown().getMessage());
42         }
43         return sb.toString();
44     }
45
46     public void setParameter(Map JavaDoc params) {
47         // we do not need any
48
}
49 }
50
Popular Tags