01: /*
02: * Created on Oct 23, 2004
03: */
04: package net.sourceforge.orbroker;
05:
06: import java.text.DateFormat;
07: import java.text.FieldPosition;
08: import java.text.SimpleDateFormat;
09: import java.util.Date;
10: import java.util.logging.Formatter;
11: import java.util.logging.LogRecord;
12:
13: /**
14: * @author Nils Kilden-Pedersen
15: */
16: final class BrokerFormatter extends Formatter {
17:
18: private static final DateFormat DATE_FORMAT = new SimpleDateFormat(
19: "yyyy.MM.dd HH:mm:ss ");
20: private static final String LINE_SEPARATOR = System
21: .getProperty("line.separator");
22: private static final FieldPosition START_POS = new FieldPosition(0);
23:
24: /**
25: * @inheritDoc
26: * @see java.util.logging.Formatter#format(java.util.logging.LogRecord)
27: */
28: public String format(LogRecord record) {
29: StringBuffer buffer = new StringBuffer();
30: DATE_FORMAT.format(new Date(record.getMillis()), buffer,
31: START_POS);
32: buffer.append(record.getLevel().toString()).append(": ");
33: buffer.append(record.getMessage()).append(LINE_SEPARATOR);
34: return buffer.toString();
35: }
36:
37: }
|