KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quickserver > util > logging > MicroFormatter


1 /*
2  * This file is part of the QuickServer library
3  * Copyright (C) 2003-2005 QuickServer.org
4  *
5  * Use, modification, copying and distribution of this software is subject to
6  * the terms and conditions of the GNU Lesser General Public License.
7  * You should have received a copy of the GNU LGP License along with this
8  * library; if not, you can download a copy from <http://www.quickserver.org/>.
9  *
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 JavaDoc;
18 import java.util.logging.*;
19
20 /**
21  * Formats the LogRecord as "LEVEL : MESSAGE"
22  */

23 public class MicroFormatter extends Formatter {
24     private String JavaDoc lineSeparator = (String JavaDoc) java.security.AccessController.doPrivileged(
25         new sun.security.action.GetPropertyAction("line.separator"));
26
27     public String JavaDoc format(LogRecord record) {
28         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
29         sb.append(record.getLevel().getLocalizedName());
30         sb.append(" : ");
31         sb.append(formatMessage(record));
32         if(record.getThrown() != null) {
33             sb.append(lineSeparator);
34             sb.append("[Exception: ");
35             sb.append(record.getThrown().toString());
36             sb.append(']');
37         }
38         sb.append(lineSeparator);
39         return sb.toString();
40     }
41 }
42
Popular Tags