001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999-2005 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: TraceEjb.java 6681 2005-05-02 15:18:31Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas_ejb.container;
025:
026: import org.objectweb.util.monolog.api.BasicLevel;
027: import org.objectweb.util.monolog.api.Logger;
028: import org.objectweb.util.monolog.api.LoggerFactory;
029: import org.objectweb.util.monolog.wrapper.printwriter.LoggerImpl;
030:
031: /**
032: * For message logging
033: * @author Sebastien Chassande-Barrioz sebastien.chassande@inrialpes.fr
034: */
035:
036: class DummyLogger extends LoggerImpl {
037:
038: /**
039: * Dummy Logger used when jotm classes are used on client side
040: */
041: public void log(int level, java.lang.Object o) {
042: }
043: }
044:
045: public class TraceEjb {
046:
047: public static Logger logger = new DummyLogger();
048: private static boolean isWarnLogger = false;
049:
050: public static Logger query = new DummyLogger();
051: private static boolean isDebugQuery = false;
052:
053: public static Logger interp = new DummyLogger();
054: private static boolean isDebugInterp = false;
055:
056: public static Logger genclass = new DummyLogger();
057: private static boolean isDebugGenclass = false;
058:
059: public static Logger coherence = new DummyLogger();
060: private static boolean isDebugCoherence = false;
061:
062: public static Logger thread = new DummyLogger();
063: private static boolean isDebugThread = false;
064:
065: public static Logger synchro = new DummyLogger();
066: private static boolean isDebugSynchro = false;
067:
068: public static Logger ssfpool = new DummyLogger();
069: private static boolean isDebugSsfpool = false;
070:
071: public static Logger swapper = new DummyLogger();
072: private static boolean isDebugSwapper = false;
073:
074: public static Logger mapper = new DummyLogger();
075: private static boolean isDebugMapper = false;
076:
077: public static Logger context = new DummyLogger();
078: private static boolean isDebugContext = false;
079:
080: public static Logger security = new DummyLogger();
081: private static boolean isDebugSecurity = false;
082:
083: public static Logger factory = new DummyLogger();
084: private static boolean isDebugFactory = false;
085:
086: public static Logger mdb = new DummyLogger();
087: private static boolean isDebugMdb = false;
088:
089: public static Logger tx = new DummyLogger();
090: private static boolean isDebugTx = false;
091:
092: public static Logger txlistener = new DummyLogger();
093: private static boolean isDebugTxlistener = false;
094:
095: public static Logger dd = new DummyLogger();
096: private static boolean isDebugDd = false;
097:
098: public static Logger loaderlog = new DummyLogger();
099: private static boolean isDebugLoaderlog = false;
100:
101: public static final String prefix = "org.objectweb.jonas_ejb";
102:
103: public static LoggerFactory loggerFactory = null;
104:
105: /**
106: * Configure loggers for monolog
107: * @param lf the logger factory
108: */
109: public static void configure(LoggerFactory lf) {
110: loggerFactory = lf;
111: logger = lf.getLogger(prefix);
112: interp = lf.getLogger(prefix + ".interp");
113: query = lf.getLogger(prefix + ".query");
114: genclass = lf.getLogger(prefix + ".genclass");
115: coherence = lf.getLogger(prefix + ".coherence");
116: thread = lf.getLogger(prefix + ".thread");
117: synchro = lf.getLogger(prefix + ".synchro");
118: ssfpool = lf.getLogger(prefix + ".ssfpool");
119: swapper = lf.getLogger(prefix + ".swapper");
120: mapper = lf.getLogger(prefix + ".mapper");
121: context = lf.getLogger(prefix + ".context");
122: security = lf.getLogger(prefix + ".security");
123: factory = lf.getLogger(prefix + ".factory");
124: mdb = lf.getLogger(prefix + ".mdb");
125: tx = lf.getLogger(prefix + ".tx");
126: txlistener = lf.getLogger(prefix + ".txlistener");
127: dd = lf.getLogger(prefix + ".dd");
128: loaderlog = lf.getLogger("org.objectweb.jonas.loader");
129: syncLevels();
130: }
131:
132: /**
133: * Sets booleans which enable debugging (debug level or Warn)
134: */
135: public static void syncLevels() {
136: // Warn
137: isWarnLogger = logger.isLoggable(BasicLevel.WARN);
138:
139: // debug
140: isDebugQuery = query.isLoggable(BasicLevel.DEBUG);
141: isDebugInterp = interp.isLoggable(BasicLevel.DEBUG);
142: isDebugGenclass = genclass.isLoggable(BasicLevel.DEBUG);
143: isDebugCoherence = coherence.isLoggable(BasicLevel.DEBUG);
144: isDebugThread = thread.isLoggable(BasicLevel.DEBUG);
145: isDebugSynchro = synchro.isLoggable(BasicLevel.DEBUG);
146: isDebugSsfpool = ssfpool.isLoggable(BasicLevel.DEBUG);
147: isDebugSwapper = swapper.isLoggable(BasicLevel.DEBUG);
148: isDebugMapper = mapper.isLoggable(BasicLevel.DEBUG);
149: isDebugContext = context.isLoggable(BasicLevel.DEBUG);
150: isDebugSecurity = security.isLoggable(BasicLevel.DEBUG);
151: isDebugFactory = factory.isLoggable(BasicLevel.DEBUG);
152: isDebugMdb = mdb.isLoggable(BasicLevel.DEBUG);
153: isDebugTx = tx.isLoggable(BasicLevel.DEBUG);
154: isDebugTxlistener = txlistener.isLoggable(BasicLevel.DEBUG);
155: isDebugDd = dd.isLoggable(BasicLevel.DEBUG);
156: isDebugLoaderlog = loaderlog.isLoggable(BasicLevel.DEBUG);
157: }
158:
159: public static final boolean isVerbose() {
160: return isWarnLogger;
161: }
162:
163: public static final boolean isDebugThread() {
164: return isDebugThread;
165: }
166:
167: public static final boolean isDebugSynchro() {
168: return isDebugSynchro;
169: }
170:
171: public static final boolean isDebugSsfpool() {
172: return isDebugSsfpool;
173: }
174:
175: public static final boolean isDebugContext() {
176: return isDebugContext;
177: }
178:
179: public static final boolean isDebugSwapper() {
180: return isDebugSwapper;
181: }
182:
183: public static final boolean isDebugMapper() {
184: return isDebugMapper;
185: }
186:
187: public static final boolean isDebugIc() {
188: return isDebugInterp;
189: }
190:
191: public static final boolean isDebugSecurity() {
192: return isDebugSecurity;
193: }
194:
195: public static final boolean isDebugFactory() {
196: return isDebugFactory;
197: }
198:
199: public static final boolean isDebugJms() {
200: return isDebugMdb;
201: }
202:
203: public static final boolean isDebugTx() {
204: return isDebugTx;
205: }
206:
207: public static final boolean isDebugTxlistener() {
208: return isDebugTxlistener;
209: }
210:
211: public static final boolean isDebugDd() {
212: return isDebugDd;
213: }
214:
215: public static final boolean isDebugQuery() {
216: return isDebugQuery;
217: }
218:
219: public static final boolean isDebugLoaderLog() {
220: return isDebugLoaderlog;
221: }
222: }
|