KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > activation > registries > LogSupport


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21
22 /*
23  * @(#)LogSupport.java 1.4 05/11/16
24  *
25  * Copyright 2002-2005 Sun Microsystems, Inc. All Rights Reserved.
26  */

27
28 package com.sun.activation.registries;
29
30 import java.io.*;
31 import java.util.logging.*;
32
33 /**
34  * Logging related methods.
35  */

36 public class LogSupport {
37     private static boolean debug = false;
38     private static Logger logger;
39     private static final Level level = Level.FINE;
40
41     static {
42     try {
43         debug = Boolean.getBoolean("javax.activation.debug");
44     } catch (Throwable JavaDoc t) {
45         // ignore any errors
46
}
47     logger = Logger.getLogger("javax.activation");
48     }
49
50     /**
51      * Constructor.
52      */

53     private LogSupport() {
54     // private constructor, can't create instances
55
}
56
57     public static void log(String JavaDoc msg) {
58     if (debug)
59         System.out.println(msg);
60     logger.log(level, msg);
61     }
62
63     public static void log(String JavaDoc msg, Throwable JavaDoc t) {
64     if (debug)
65         System.out.println(msg + "; Exception: " + t);
66     logger.log(level, msg, t);
67     }
68
69     public static boolean isLoggable() {
70     return debug || logger.isLoggable(level);
71     }
72 }
73
Popular Tags