01: package org.jzonic.jlo.formatter;
02:
03: import org.jzonic.jlo.LogRecord;
04:
05: import java.util.Map;
06:
07: /**
08: * The SimpleFormatter is a concrete implementation of a Formatter.
09: * The format is:
10: * <pre>
11: * [target] text of the message
12: * </pre>
13: *
14: *@author Andreas Mecky
15: *@author Terry Dye
16: */
17: public class PlainFormatter extends AbstractFormatter {
18: /**
19: * Constructor for the SimpleFormatter object
20: */
21: public PlainFormatter(String configName) {
22: super (configName);
23: }
24:
25: /**
26: *@param lr The LogRecord
27: *@return The message as string that should be logged
28: */
29: public String formatMessage(LogRecord lr) {
30: StringBuffer sb = new StringBuffer();
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 params) {
47: // we do not need any
48: }
49: }
|