KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_ejb > container > TraceEjb


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999-2005 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: TraceEjb.java,v 1.32 2005/05/02 15:18:31 benoitf Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas_ejb.container;
27
28 import org.objectweb.util.monolog.api.BasicLevel;
29 import org.objectweb.util.monolog.api.Logger;
30 import org.objectweb.util.monolog.api.LoggerFactory;
31 import org.objectweb.util.monolog.wrapper.printwriter.LoggerImpl;
32
33 /**
34  * For message logging
35  * @author Sebastien Chassande-Barrioz sebastien.chassande@inrialpes.fr
36  */

37
38 class DummyLogger extends LoggerImpl {
39
40     /**
41      * Dummy Logger used when jotm classes are used on client side
42      */

43     public void log(int level, java.lang.Object JavaDoc o) {
44     }
45 }
46
47 public class TraceEjb {
48
49     public static Logger logger = new DummyLogger();
50     private static boolean isWarnLogger = false;
51
52     public static Logger query = new DummyLogger();
53     private static boolean isDebugQuery = false;
54
55     public static Logger interp = new DummyLogger();
56     private static boolean isDebugInterp = false;
57
58     public static Logger genclass = new DummyLogger();
59     private static boolean isDebugGenclass = false;
60
61     public static Logger coherence = new DummyLogger();
62     private static boolean isDebugCoherence = false;
63
64     public static Logger thread = new DummyLogger();
65     private static boolean isDebugThread = false;
66
67     public static Logger synchro = new DummyLogger();
68     private static boolean isDebugSynchro = false;
69
70     public static Logger ssfpool = new DummyLogger();
71     private static boolean isDebugSsfpool = false;
72
73     public static Logger swapper = new DummyLogger();
74     private static boolean isDebugSwapper = false;
75
76     public static Logger mapper = new DummyLogger();
77     private static boolean isDebugMapper = false;
78
79     public static Logger context = new DummyLogger();
80     private static boolean isDebugContext = false;
81
82     public static Logger security = new DummyLogger();
83     private static boolean isDebugSecurity = false;
84
85     public static Logger factory = new DummyLogger();
86     private static boolean isDebugFactory = false;
87
88     public static Logger mdb = new DummyLogger();
89     private static boolean isDebugMdb = false;
90
91     public static Logger tx = new DummyLogger();
92     private static boolean isDebugTx = false;
93
94     public static Logger txlistener = new DummyLogger();
95     private static boolean isDebugTxlistener = false;
96
97     public static Logger dd = new DummyLogger();
98     private static boolean isDebugDd = false;
99
100     public static Logger loaderlog = new DummyLogger();
101     private static boolean isDebugLoaderlog = false;
102
103
104     public static final String JavaDoc prefix = "org.objectweb.jonas_ejb";
105
106     public static LoggerFactory loggerFactory = null;
107
108     /**
109      * Configure loggers for monolog
110      * @param lf the logger factory
111      */

112     public static void configure(LoggerFactory lf) {
113         loggerFactory = lf;
114         logger = lf.getLogger(prefix);
115         interp = lf.getLogger(prefix + ".interp");
116         query = lf.getLogger(prefix + ".query");
117         genclass = lf.getLogger(prefix + ".genclass");
118         coherence = lf.getLogger(prefix + ".coherence");
119         thread = lf.getLogger(prefix + ".thread");
120         synchro = lf.getLogger(prefix + ".synchro");
121         ssfpool = lf.getLogger(prefix + ".ssfpool");
122         swapper = lf.getLogger(prefix + ".swapper");
123         mapper = lf.getLogger(prefix + ".mapper");
124         context = lf.getLogger(prefix + ".context");
125         security = lf.getLogger(prefix + ".security");
126         factory = lf.getLogger(prefix + ".factory");
127         mdb = lf.getLogger(prefix + ".mdb");
128         tx = lf.getLogger(prefix + ".tx");
129         txlistener = lf.getLogger(prefix + ".txlistener");
130         dd = lf.getLogger(prefix + ".dd");
131         loaderlog = lf.getLogger("org.objectweb.jonas.loader");
132         syncLevels();
133     }
134
135     /**
136      * Sets booleans which enable debugging (debug level or Warn)
137      */

138     public static void syncLevels() {
139         // Warn
140
isWarnLogger = logger.isLoggable(BasicLevel.WARN);
141
142         // debug
143
isDebugQuery = query.isLoggable(BasicLevel.DEBUG);
144         isDebugInterp = interp.isLoggable(BasicLevel.DEBUG);
145         isDebugGenclass = genclass.isLoggable(BasicLevel.DEBUG);
146         isDebugCoherence = coherence.isLoggable(BasicLevel.DEBUG);
147         isDebugThread = thread.isLoggable(BasicLevel.DEBUG);
148         isDebugSynchro = synchro.isLoggable(BasicLevel.DEBUG);
149         isDebugSsfpool = ssfpool.isLoggable(BasicLevel.DEBUG);
150         isDebugSwapper = swapper.isLoggable(BasicLevel.DEBUG);
151         isDebugMapper = mapper.isLoggable(BasicLevel.DEBUG);
152         isDebugContext = context.isLoggable(BasicLevel.DEBUG);
153         isDebugSecurity = security.isLoggable(BasicLevel.DEBUG);
154         isDebugFactory = factory.isLoggable(BasicLevel.DEBUG);
155         isDebugMdb = mdb.isLoggable(BasicLevel.DEBUG);
156         isDebugTx = tx.isLoggable(BasicLevel.DEBUG);
157         isDebugTxlistener = txlistener.isLoggable(BasicLevel.DEBUG);
158         isDebugDd = dd.isLoggable(BasicLevel.DEBUG);
159         isDebugLoaderlog = loaderlog.isLoggable(BasicLevel.DEBUG);
160     }
161
162
163     public static final boolean isVerbose() {
164         return isWarnLogger;
165     }
166
167     public static final boolean isDebugThread() {
168         return isDebugThread;
169     }
170
171     public static final boolean isDebugSynchro() {
172         return isDebugSynchro;
173     }
174
175     public static final boolean isDebugSsfpool() {
176         return isDebugSsfpool;
177     }
178
179     public static final boolean isDebugContext() {
180         return isDebugContext;
181     }
182
183     public static final boolean isDebugSwapper() {
184         return isDebugSwapper;
185     }
186
187     public static final boolean isDebugMapper() {
188         return isDebugMapper;
189     }
190
191     public static final boolean isDebugIc() {
192         return isDebugInterp;
193     }
194
195     public static final boolean isDebugSecurity() {
196         return isDebugSecurity;
197     }
198
199     public static final boolean isDebugFactory() {
200         return isDebugFactory;
201     }
202
203     public static final boolean isDebugJms() {
204         return isDebugMdb;
205     }
206
207     public static final boolean isDebugTx() {
208         return isDebugTx;
209     }
210
211     public static final boolean isDebugTxlistener() {
212         return isDebugTxlistener;
213     }
214
215     public static final boolean isDebugDd() {
216         return isDebugDd;
217     }
218
219     public static final boolean isDebugQuery() {
220         return isDebugQuery;
221     }
222
223     public static final boolean isDebugLoaderLog() {
224         return isDebugLoaderlog;
225     }
226 }
227
Popular Tags