01: /*
02: * This file is part of the QuickServer library
03: * Copyright (C) 2003-2005 QuickServer.org
04: *
05: * Use, modification, copying and distribution of this software is subject to
06: * the terms and conditions of the GNU Lesser General Public License.
07: * You should have received a copy of the GNU LGP License along with this
08: * library; if not, you can download a copy from <http://www.quickserver.org/>.
09: *
10: * For questions, suggestions, bug-reports, enhancement-requests etc.
11: * visit http://www.quickserver.org
12: *
13: */
14:
15: package org.quickserver.util.logging;
16:
17: import java.util.Date;
18: import java.util.logging.*;
19:
20: /**
21: * Formats the LogRecord as "LEVEL : MESSAGE"
22: */
23: public class MicroFormatter extends Formatter {
24: private String lineSeparator = (String) java.security.AccessController
25: .doPrivileged(new sun.security.action.GetPropertyAction(
26: "line.separator"));
27:
28: public String format(LogRecord record) {
29: StringBuffer sb = new StringBuffer();
30: sb.append(record.getLevel().getLocalizedName());
31: sb.append(" : ");
32: sb.append(formatMessage(record));
33: if (record.getThrown() != null) {
34: sb.append(lineSeparator);
35: sb.append("[Exception: ");
36: sb.append(record.getThrown().toString());
37: sb.append(']');
38: }
39: sb.append(lineSeparator);
40: return sb.toString();
41: }
42: }
|