Author: dallen6
Date: 2009-03-16 06:58:56 -0400 (Mon, 16 Mar 2009)
New Revision: 2032
Added:
extensions/trunk/logging/.settings/
extensions/trunk/logging/.settings/org.maven.ide.eclipse.prefs
extensions/trunk/logging/src/main/java/org/
extensions/trunk/logging/src/main/java/org/jboss/
extensions/trunk/logging/src/main/java/org/jboss/webbeans/
extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/
extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/JDKProvider.java
extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/Log.java
extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/Log4JProvider.java
extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/LogImpl.java
extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/LogProvider.java
extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/Logging.java
Modified:
extensions/trunk/logging/
Log:
New logging project to be used by Web Beans and Seam projects
Property changes on: extensions/trunk/logging
___________________________________________________________________
Name: svn:ignore
+ .project
.classpath
target
Added: extensions/trunk/logging/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- extensions/trunk/logging/.settings/org.maven.ide.eclipse.prefs
(rev 0)
+++ extensions/trunk/logging/.settings/org.maven.ide.eclipse.prefs 2009-03-16 10:58:56 UTC
(rev 2032)
@@ -0,0 +1,8 @@
+#Mon Mar 16 11:30:27 CET 2009
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+version=1
Property changes on: extensions/trunk/logging/.settings/org.maven.ide.eclipse.prefs
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/JDKProvider.java
===================================================================
--- extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/JDKProvider.java
(rev 0)
+++
extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/JDKProvider.java 2009-03-16
10:58:56 UTC (rev 2032)
@@ -0,0 +1,156 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.log;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author Gavin King
+ *
+ */
+class JDKProvider implements LogProvider
+{
+ private final Logger logger;
+ private final boolean isWrapped;
+
+ JDKProvider(String category, boolean wrapped)
+ {
+ this.logger = Logger.getLogger(category);
+ this.isWrapped = wrapped;
+ }
+
+ private void log(Level level, Object object, Throwable ex)
+ {
+
+ if (logger.isLoggable(level))
+ {
+ Throwable dummyException = new Throwable();
+ StackTraceElement locations[] = dummyException.getStackTrace();
+ String className = "unknown";
+ String methodName = "unknown";
+ int depth = isWrapped ? 3 : 2;
+ if (locations != null && locations.length > depth)
+ {
+ StackTraceElement caller = locations[depth];
+ className = caller.getClassName();
+ methodName = caller.getMethodName();
+ }
+ if (ex == null)
+ {
+ logger.logp(level, className, methodName, String.valueOf(object));
+ }
+ else
+ {
+ logger.logp(level, className, methodName, String.valueOf(object), ex);
+ }
+ }
+
+ }
+
+ public void debug(Object object, Throwable t)
+ {
+ log(Level.FINE, object, t);
+ }
+
+ public void debug(Object object)
+ {
+ log(Level.FINE, object, null);
+ }
+
+ public void error(Object object, Throwable t)
+ {
+ log(Level.SEVERE, object, t);
+ }
+
+ public void error(Object object)
+ {
+ log(Level.SEVERE, object, null);
+ }
+
+ public void fatal(Object object, Throwable t)
+ {
+ log(Level.SEVERE, object, t);
+ }
+
+ public void fatal(Object object)
+ {
+ log(Level.SEVERE, object, null);
+ }
+
+ public void info(Object object, Throwable t)
+ {
+ log(Level.INFO, object, t);
+ }
+
+ public void info(Object object)
+ {
+ log(Level.INFO, object, null);
+ }
+
+ public boolean isDebugEnabled()
+ {
+ return logger.isLoggable(Level.FINE);
+ }
+
+ public boolean isErrorEnabled()
+ {
+ return logger.isLoggable(Level.SEVERE);
+ }
+
+ public boolean isFatalEnabled()
+ {
+ return logger.isLoggable(Level.SEVERE);
+ }
+
+ public boolean isInfoEnabled()
+ {
+ return logger.isLoggable(Level.INFO);
+ }
+
+ public boolean isTraceEnabled()
+ {
+ return logger.isLoggable(Level.FINER);
+ }
+
+ public boolean isWarnEnabled()
+ {
+ return logger.isLoggable(Level.WARNING);
+ }
+
+ public void trace(Object object, Throwable t)
+ {
+ log(Level.FINER, object, t);
+ }
+
+ public void trace(Object object)
+ {
+ log(Level.FINER, object, null);
+ }
+
+ public void warn(Object object, Throwable t)
+ {
+ log(Level.WARNING, object, t);
+ }
+
+ public void warn(Object object)
+ {
+ log(Level.WARNING, object, null);
+ }
+
+}
Property changes on:
extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/JDKProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/Log.java
===================================================================
--- extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/Log.java
(rev 0)
+++ extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/Log.java 2009-03-16
10:58:56 UTC (rev 2032)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.log;
+
+/**
+ * <p>A <code>Log</code> object is used by RI classes to log messages.
+ * They will be logged in any environment that has setup a logging service
+ * such as Log4J or the standard JDK logging facilities. In fact, this
+ * logging interface is very similar to the other facilities with the
+ * difference that logging methods also take any number of optional
+ * parameters beyond the message object for later interpolation
+ * into the message.</p>
+ *
+ * <p>The idea of using interpolation parameters is very important for
+ * performance reasons in production code. Normally developers write
+ * logging messages similar to this one:
+ * <pre>
+ * log.debug("Started processing of " + obj1 + " with action " +
obj2);
+ * </pre>
+ * The problem that arises at runtime in production systems, is that DEBUG
+ * level logging may not be enabled. And even if this logging is going to
+ * be a no-op call, Java must still build the string dynamically that is the
+ * argument to the call. It is the building of this string that can be quite
+ * time consuming. The more complex the objects being concatenated are, the
+ * worse the time penalty incurred is. And this time is completely wasted
+ * since the string may never be used.</p>
+ *
+ * <p>Normally to combat the problem of making this call and building the
+ * string dynamically, the developer uses a conditional statement to invoke
+ * the call only if the corresponding logging level is enabled. So the above
+ * call may end up looking like:
+ * <pre>
+ * if (log.isDebugEnabled())
+ * {
+ * log.debug("Started processing of " + obj1 + " with action "
+ obj2);
+ * }
+ * </pre>
+ * Ideally, this structure should always be used to avoid the cost of building the
+ * dynamic string (concatenation) and making the unnecessary call. The only
+ * drawback to this is that code can become less readable. In some cases, there
+ * might be more code devoted to logging than the actual behavior required by a
+ * method.</p>
+ *
+ * <p>A cleaner way to do the logging is to use this interface where simple
+ * objects without any concatenation are passed as arguments. Albeit the call
+ * itself may still be a no-op when the logging level is not enabled, this is
+ * still much smaller than the concatenation process with dynamic strings. Each
+ * of the methods defined here will first check to see if the logging level is enabled,
+ * if that feature exists in the underlying logging system. If and only if that logging
+ * level is enabled, will the implementation proceed with concatenation of the strings
+ * and objects passed. So the above code using this interface becomes:
+ * <pre>
+ * log.debug("Started processing of {0} with action {1}, obj1, obj2);
+ * </pre>
+ * </p>
+ *
+ * <p>The interpolation of parameters into the message string are done using
+ * {@link java.text.MessageFormat}. See the documentation on that class for
+ * more ideas of interpolation possibilities. In the above code,
<code>obj1</code>
+ * and <code>obj2</code> simply have their
<code>toString()</code> methods invoked
+ * to produce a string which is then concatenated.</p>
+ *
+ * @author Gavin King
+ * @author David Allen
+ *
+ */
+public interface Log
+{
+ public boolean isDebugEnabled();
+ public boolean isErrorEnabled();
+ public boolean isFatalEnabled();
+ public boolean isInfoEnabled();
+ public boolean isTraceEnabled();
+ public boolean isWarnEnabled();
+ public void trace(Object object, Object... params);
+ public void trace(Object object, Throwable t, Object... params);
+ public void debug(Object object, Object... params);
+ public void debug(Object object, Throwable t, Object... params);
+ public void info(Object object, Object... params);
+ public void info(Object object, Throwable t, Object... params);
+ public void warn(Object object, Object... params);
+ public void warn(Object object, Throwable t, Object... params);
+ public void error(Object object, Object... params);
+ public void error(Object object, Throwable t, Object... params);
+ public void fatal(Object object, Object... params);
+ public void fatal(Object object, Throwable t, Object... params);
+
+}
\ No newline at end of file
Property changes on:
extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/Log.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/Log4JProvider.java
===================================================================
--- extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/Log4JProvider.java
(rev 0)
+++
extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/Log4JProvider.java 2009-03-16
10:58:56 UTC (rev 2032)
@@ -0,0 +1,151 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.log;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
+/**
+ *
+ * @author Gavin King
+ *
+ */
+final class Log4JProvider implements LogProvider
+{
+ private final Logger logger;
+ private final boolean isWrapped;
+
+ private static final String LOG_IMPL_FQCN = LogImpl.class.getName();
+ private static final String LOG_PROVIDER_FQCN = Log4JProvider.class.getName();
+
+ private static final Level TRACE;
+ static
+ {
+ Object trace;
+ try
+ {
+ trace = Level.class.getDeclaredField("TRACE").get(null);
+ }
+ catch (Exception e)
+ {
+ trace = Level.DEBUG;
+ }
+ TRACE = (Level) trace;
+ }
+
+ Log4JProvider(String category, boolean wrapped)
+ {
+ logger = Logger.getLogger(category);
+ isWrapped = wrapped;
+ }
+
+ private String getFQCN()
+ {
+ return isWrapped ? LOG_IMPL_FQCN : LOG_PROVIDER_FQCN;
+ }
+
+ public void debug(Object object)
+ {
+ logger.log(getFQCN(), Level.DEBUG, object, null);
+ }
+
+ public void debug(Object object, Throwable t)
+ {
+ logger.log(getFQCN(), Level.DEBUG, object, t);
+ }
+
+ public void error(Object object)
+ {
+ logger.log(getFQCN(), Level.ERROR, object, null);
+ }
+
+ public void error(Object object, Throwable t)
+ {
+ logger.log(getFQCN(), Level.ERROR, object, t);
+ }
+
+ public void fatal(Object object)
+ {
+ logger.log(getFQCN(), Level.FATAL, object, null);
+ }
+
+ public void fatal(Object object, Throwable t)
+ {
+ logger.log(getFQCN(), Level.FATAL, object, t);
+ }
+
+ public void info(Object object)
+ {
+ logger.log(getFQCN(), Level.INFO, object, null);
+ }
+
+ public void info(Object object, Throwable t)
+ {
+ logger.log(getFQCN(), Level.INFO, object, t);
+ }
+
+ public boolean isDebugEnabled()
+ {
+ return logger.isEnabledFor(Level.DEBUG);
+ }
+
+ public boolean isErrorEnabled()
+ {
+ return logger.isEnabledFor(Level.ERROR);
+ }
+
+ public boolean isFatalEnabled()
+ {
+ return logger.isEnabledFor(Level.FATAL);
+ }
+
+ public boolean isInfoEnabled()
+ {
+ return logger.isEnabledFor(Level.INFO);
+ }
+
+ public boolean isTraceEnabled()
+ {
+ return logger.isEnabledFor(TRACE);
+ }
+
+ public boolean isWarnEnabled()
+ {
+ return logger.isEnabledFor(Level.WARN);
+ }
+
+ public void trace(Object object)
+ {
+ logger.log(getFQCN(), TRACE, object, null);
+ }
+
+ public void trace(Object object, Throwable t)
+ {
+ logger.log(getFQCN(), TRACE, object, t);
+ }
+
+ public void warn(Object object)
+ {
+ logger.log(getFQCN(), Level.WARN, object, null);
+ }
+
+ public void warn(Object object, Throwable t)
+ {
+ logger.log(getFQCN(), Level.WARN, object, t);
+ }
+
+}
Property changes on:
extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/Log4JProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/LogImpl.java
===================================================================
--- extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/LogImpl.java
(rev 0)
+++ extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/LogImpl.java 2009-03-16
10:58:56 UTC (rev 2032)
@@ -0,0 +1,192 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.log;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.text.MessageFormat;
+
+/**
+ *
+ * @author Gavin King
+ *
+ */
+class LogImpl implements Log, Externalizable
+{
+ private transient LogProvider log;
+ private String category;
+
+ public LogImpl()
+ {
+ }
+
+ LogImpl(String category)
+ {
+ this.category = category;
+ this.log = Logging.getLogProvider(category, true);
+ }
+
+ public boolean isDebugEnabled()
+ {
+ return log.isDebugEnabled();
+ }
+
+ public boolean isErrorEnabled()
+ {
+ return log.isErrorEnabled();
+ }
+
+ public boolean isFatalEnabled()
+ {
+ return log.isFatalEnabled();
+ }
+
+ public boolean isInfoEnabled()
+ {
+ return log.isInfoEnabled();
+ }
+
+ public boolean isTraceEnabled()
+ {
+ return log.isTraceEnabled();
+ }
+
+ public boolean isWarnEnabled()
+ {
+ return log.isWarnEnabled();
+ }
+
+ public void trace(Object object, Object... params)
+ {
+ if (isTraceEnabled())
+ {
+ log.trace(interpolate(object, params));
+ }
+ }
+
+ public void trace(Object object, Throwable t, Object... params)
+ {
+ if (isTraceEnabled())
+ {
+ log.trace(interpolate(object, params), t);
+ }
+ }
+
+ public void debug(Object object, Object... params)
+ {
+ if (isDebugEnabled())
+ {
+ log.debug(interpolate(object, params));
+ }
+ }
+
+ public void debug(Object object, Throwable t, Object... params)
+ {
+ if (isDebugEnabled())
+ {
+ log.debug(interpolate(object, params), t);
+ }
+ }
+
+ public void info(Object object, Object... params)
+ {
+ if (isInfoEnabled())
+ {
+ log.info(interpolate(object, params));
+ }
+ }
+
+ public void info(Object object, Throwable t, Object... params)
+ {
+ if (isInfoEnabled())
+ {
+ log.info(interpolate(object, params), t);
+ }
+ }
+
+ public void warn(Object object, Object... params)
+ {
+ if (isWarnEnabled())
+ {
+ log.warn(interpolate(object, params));
+ }
+ }
+
+ public void warn(Object object, Throwable t, Object... params)
+ {
+ if (isWarnEnabled())
+ {
+ log.warn(interpolate(object, params), t);
+ }
+ }
+
+ public void error(Object object, Object... params)
+ {
+ if (isErrorEnabled())
+ {
+ log.error(interpolate(object, params));
+ }
+ }
+
+ public void error(Object object, Throwable t, Object... params)
+ {
+ if (isErrorEnabled())
+ {
+ log.error(interpolate(object, params), t);
+ }
+ }
+
+ public void fatal(Object object, Object... params)
+ {
+ if (isFatalEnabled())
+ {
+ log.fatal(interpolate(object, params));
+ }
+ }
+
+ public void fatal(Object object, Throwable t, Object... params)
+ {
+ if (isFatalEnabled())
+ {
+ log.fatal(interpolate(object, params), t);
+ }
+ }
+
+ private Object interpolate(Object message, Object... params)
+ {
+ Object interpolatedMessage = message;
+ if (params.length > 0)
+ {
+ interpolatedMessage = MessageFormat.format(message.toString(), params);
+ }
+ return interpolatedMessage;
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ category = (String) in.readObject();
+ log = Logging.getLogProvider(category, true);
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ out.writeObject(category);
+ }
+
+}
Property changes on:
extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/LogImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/LogProvider.java
===================================================================
--- extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/LogProvider.java
(rev 0)
+++
extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/LogProvider.java 2009-03-16
10:58:56 UTC (rev 2032)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.log;
+
+/**
+ *
+ * @author Gavin King
+ *
+ */
+public interface LogProvider
+{
+ public void trace(Object object);
+ public void trace(Object object, Throwable t);
+ public void debug(Object object);
+ public void debug(Object object, Throwable t);
+ public void info(Object object);
+ public void info(Object object, Throwable t);
+ public void warn(Object object);
+ public void warn(Object object, Throwable t);
+ public void error(Object object);
+ public void error(Object object, Throwable t);
+ public void fatal(Object object);
+ public void fatal(Object object, Throwable t);
+ public boolean isTraceEnabled();
+ public boolean isDebugEnabled();
+ public boolean isInfoEnabled();
+ public boolean isWarnEnabled();
+ public boolean isErrorEnabled();
+ public boolean isFatalEnabled();
+}
Property changes on:
extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/LogProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/Logging.java
===================================================================
--- extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/Logging.java
(rev 0)
+++ extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/Logging.java 2009-03-16
10:58:56 UTC (rev 2032)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.log;
+
+/**
+ *
+ * @author Gavin King
+ *
+ */
+public class Logging
+{
+ private static final boolean isLog4JAvailable;
+
+ static
+ {
+ boolean available;
+ try
+ {
+ Class.forName("org.apache.log4j.Logger");
+ available = true;
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ available = false;
+ }
+ isLog4JAvailable = available;
+ }
+
+ public static Log getLog(String category)
+ {
+ return new LogImpl(category);
+ }
+
+ public static Log getLog(Class<?> clazz)
+ {
+ return new LogImpl(clazz.getName());
+ }
+
+ static LogProvider getLogProvider(String category, boolean wrapped)
+ {
+ return isLog4JAvailable ? new Log4JProvider(category, wrapped) : new
JDKProvider(category, wrapped);
+ }
+
+ public static LogProvider getLogProvider(Class<?> clazz)
+ {
+ return getLogProvider(clazz.getName(), false);
+ }
+
+}
Property changes on:
extensions/trunk/logging/src/main/java/org/jboss/webbeans/log/Logging.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain