[jboss-svn-commits] JBL Code SVN: r29868 - in labs/jbosstm/trunk: XTS/WS-T/dev/src/org/jboss/jbossts/xts/recovery/participant/at and 9 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Oct 29 10:15:19 EDT 2009
Author: jhalliday
Date: 2009-10-29 10:15:18 -0400 (Thu, 29 Oct 2009)
New Revision: 29868
Added:
labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/Logi18nImpl.java
labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/basic/
labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/basic/BasicLog.java
labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/basic/BasicLogEnvironmentBean.java
labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/basic/BasicLogFactory.java
Removed:
labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/AbstractLogImpl.java
labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/AbstractLogInterface.java
labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/DefaultLog.java
labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/DefaultLogEnvironmentBean.java
labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LogImpl.java
Modified:
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/recovery/RecoveryManagerImple.java
labs/jbosstm/trunk/XTS/WS-T/dev/src/org/jboss/jbossts/xts/recovery/participant/at/ATParticipantRecoveryRecord.java
labs/jbosstm/trunk/atsintegration/transaction-jboss-beans.xml
labs/jbosstm/trunk/atsintegration/transaction-jboss-beans.xml.jts
labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LogFactoryInterface.java
labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LogInterface.java
labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LogNoi18nImpl.java
labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LoggingEnvironmentBean.java
labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LoggingEnvironmentBeanMBean.java
labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/commonPropertyManager.java
labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/jakarta/JakartaLogFactory.java
labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/jakarta/Log4JLogger.java
labs/jbosstm/trunk/common/classes/com/arjuna/common/util/logging/LogFactory.java
labs/jbosstm/trunk/common/classes/com/arjuna/common/util/logging/LogNoi18n.java
labs/jbosstm/trunk/common/classes/com/arjuna/common/util/logging/Logi18n.java
labs/jbosstm/trunk/common/tests/com/arjuna/common/tests/simple/BeanPopulatorTest.java
labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/debugextension/DebugExt.java
labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/i18n/logi18n.java
labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/testlevels/TestLevels.java
Log:
CLF cleanup. JBTM-638
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/recovery/RecoveryManagerImple.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/recovery/RecoveryManagerImple.java 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/recovery/RecoveryManagerImple.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -81,16 +81,6 @@
public RecoveryManagerImple (boolean threaded)
{
- // force normal recovery trace on
- tsLogger.arjLogger.mergeFacilityCode(FacilityCode.FAC_RECOVERY_NORMAL);
- tsLogger.arjLoggerI18N
- .mergeFacilityCode(FacilityCode.FAC_RECOVERY_NORMAL);
-
- /*
- * This next would force debugging on, but separate recovery mgr file
- * makes this unnecessary.
- */
-
Implementations.initialise();
Modified: labs/jbosstm/trunk/XTS/WS-T/dev/src/org/jboss/jbossts/xts/recovery/participant/at/ATParticipantRecoveryRecord.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src/org/jboss/jbossts/xts/recovery/participant/at/ATParticipantRecoveryRecord.java 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src/org/jboss/jbossts/xts/recovery/participant/at/ATParticipantRecoveryRecord.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -160,7 +160,7 @@
// the original participant did not provide a way to save its state so
// throw an exception to notify this
- String mesg = WSTLogger.arjLoggerI18N.getString("org.jboss.transactions.xts.recovery.participant.at.ATParticipantRecoveryRecord.restoreParticipant_1", id);
+ String mesg = WSTLogger.arjLoggerI18N.getString("org.jboss.transactions.xts.recovery.participant.at.ATParticipantRecoveryRecord.restoreParticipant_1", new Object[] {id});
throw new Exception(mesg);
}
Modified: labs/jbosstm/trunk/atsintegration/transaction-jboss-beans.xml
===================================================================
--- labs/jbosstm/trunk/atsintegration/transaction-jboss-beans.xml 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/atsintegration/transaction-jboss-beans.xml 2009-10-29 14:15:18 UTC (rev 29868)
@@ -2,7 +2,7 @@
<deployment xmlns="urn:jboss:bean-deployer:2.0">
<!--
- This is an example transaction-jboss-beans.xml file suitable for installing JBossTS 4.8 JTA
+ This is an example transaction-jboss-beans.xml file suitable for installing JBossTS 4.9 JTA
into AS 6.0 alpha. The canonical version of this file normally resides in the JBossAS svn
but right now JBossAS is running an earlier TS release, so we provide this file via the
JBossTS svn as an example to facilitate upgrading. Take care - some non-arjuna beans many have
@@ -20,7 +20,7 @@
<constructor factoryClass="com.arjuna.common.internal.util.logging.commonPropertyManager" factoryMethod="getLoggingEnvironmentBean"/>
- <property name="loggingSystem">log4j_releveler</property>
+ <property name="loggingFactory">com.arjuna.common.internal.util.logging.jakarta.JakartaRelevelingLogFactory;com.arjuna.common.internal.util.logging.jakarta.Log4JLogger</property>
</bean>
Modified: labs/jbosstm/trunk/atsintegration/transaction-jboss-beans.xml.jts
===================================================================
--- labs/jbosstm/trunk/atsintegration/transaction-jboss-beans.xml.jts 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/atsintegration/transaction-jboss-beans.xml.jts 2009-10-29 14:15:18 UTC (rev 29868)
@@ -2,7 +2,7 @@
<deployment xmlns="urn:jboss:bean-deployer:2.0">
<!--
- This is an example transaction-jboss-beans.xml file suitable for installing JBossTS 4.8 JTS
+ This is an example transaction-jboss-beans.xml file suitable for installing JBossTS 4.9 JTS
into AS 6.0 alpha. The canonical version of this file normally resides in the JBossAS svn
but right now JBossAS is running an earlier TS release, so we provide this file via the
JBossTS svn as an example to facilitate upgrading. Take care - some non-arjuna beans many have
@@ -20,7 +20,7 @@
<constructor factoryClass="com.arjuna.common.internal.util.logging.commonPropertyManager" factoryMethod="getLoggingEnvironmentBean"/>
- <property name="loggingSystem">log4j_releveler</property>
+ <property name="loggingFactory">com.arjuna.common.internal.util.logging.jakarta.JakartaRelevelingLogFactory;com.arjuna.common.internal.util.logging.jakarta.Log4JLogger</property>
</bean>
Deleted: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/AbstractLogImpl.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/AbstractLogImpl.java 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/AbstractLogImpl.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -1,725 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-/*
-* LogImpl.java
-*
-* Copyright (c) 2003 Arjuna Technologies Ltd.
-* Arjuna Technologies Ltd. Confidential
-*
-* Created on Jun 30, 2003, 12:48:49 PM by Thomas Rischbeck
-*/
-package com.arjuna.common.internal.util.logging;
-
-import com.arjuna.common.util.logging.*;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import java.util.PropertyResourceBundle;
-import java.util.Locale;
-import java.text.MessageFormat;
-
-/**
- * Abstract implementation of the Log interface.
- *
- * Abstract superclass for {@link LogImpl LogImpl}
- * This contains the support for finer-grained logging and guards (e.g.,
- * isWarnEnabled(), etc.).
- *
- * @author Thomas Rischbeck <thomas.rischbeck at arjuna.com>
- * @version $Revision: 2342 $ $Date: 2006-03-30 14:06:17 +0100 (Thu, 30 Mar 2006) $
- * @since clf-2.0
- */
-public abstract class AbstractLogImpl implements Logi18n
-{
-
- /**
- * Abstract Log interface (extended by i18n enabled or non-i18n log interfaces).
- */
- private AbstractLogInterface m_logInterface = null;
-
- private ResourceBundle m_defaultResourceBundle = null;
-
- /**
- * extra resource bundles (if more than one is in use)
- *
- * Note that there is a performance issue when more than one resource bundles is in use.
- *
- * @see #m_defaultResourceBundle
- */
- private ResourceBundle[] m_extraResourceBundles = null;
-
- /**
- * Level for finer-debug logging.
- *
- * @see DebugLevel for possible values.
- */
- private long m_debugLevel = DebugLevel.NO_DEBUGGING;
-
- /**
- * log level for visibility-based logging
- *
- * @see VisibilityLevel for possible values.
- */
- private long m_visLevel = VisibilityLevel.VIS_ALL;
-
- /**
- * log level for facility code
- *
- * @see FacilityCode for possible values.
- */
- private long m_facLevel = FacilityCode.FAC_ALL;
-
-
- /**
- * constructor
- *
- * @param logInterface the AbstractLogInterface
- */
- public AbstractLogImpl(AbstractLogInterface logInterface)
- {
- m_logInterface = logInterface;
- }
-
- /**
- * constructor
- *
- * @param logInterface the AbstractLogInterface
- * @param resBundle bundle used for this logger (if a resource bundle is used per logger)
- */
- public AbstractLogImpl(AbstractLogInterface logInterface, String resBundle)
- {
- m_logInterface = logInterface;
- //m_resourceBundleName = resBundle;
- //m_defaultResourceBundle = PropertyResourceBundle.getBundle(resBundle);
- addResourceBundle(resBundle);
- }
-
- /**
- * Set the name of the resource bundle name that the logger will use
- * to retreive national text
- *
- * @param baseName The default resource bundle name the logger uses to retreive messages
- */
- public synchronized void setResourceBundleName(String baseName)
- {
- try
- {
- m_defaultResourceBundle = PropertyResourceBundle.getBundle(baseName, Locale.getDefault(), Thread.currentThread().getContextClassLoader());
- }
- catch (MissingResourceException mre)
- {
- System.err.println("resource bundle " + mre.getClassName() + " not found!");
- }
- }
-
- /**
- * Add the given resource bundle to this logger.
- *
- * @param bundleName The name of the resource bundle.
- */
- public synchronized void addResourceBundle(String bundleName)
- {
- try
- {
- // if no default resource bundle has been set, use this one as the default one
- if (m_defaultResourceBundle == null)
- {
- m_defaultResourceBundle = PropertyResourceBundle.getBundle(bundleName, Locale.getDefault(), Thread.currentThread().getContextClassLoader());
- }
-
- // otherwise, add it to the extra resource bundles supported by this logger
- else if (m_extraResourceBundles == null)
- {
- m_extraResourceBundles = new ResourceBundle[]{PropertyResourceBundle.getBundle(bundleName, Locale.getDefault(), Thread.currentThread().getContextClassLoader())};
- }
- else
- {
- ResourceBundle[] oldExtraResBundles = m_extraResourceBundles;
- m_extraResourceBundles = new ResourceBundle[oldExtraResBundles.length + 1];
- System.arraycopy(oldExtraResBundles, 0, m_extraResourceBundles, 0, oldExtraResBundles.length);
- m_extraResourceBundles[oldExtraResBundles.length] = PropertyResourceBundle.getBundle(bundleName, Locale.getDefault(), Thread.currentThread().getContextClassLoader());
- }
- }
- catch (MissingResourceException mre)
- {
- System.err.println("resource bundle " + mre.getClassName() + " not found!");
- }
- }
-
-
- /**
- * Determine if this logger is enabled for DEBUG messages.
- * @return True if the logger is enabled for DEBUG, false otherwise
- */
- public boolean isDebugEnabled()
- {
- return m_logInterface.isDebugEnabled();
- }
-
- /**
- * Determine if this logger is enabled for INFO messages.
- * @return True if the logger is enabled for INFO, false otherwise
- */
- public boolean isInfoEnabled()
- {
- return m_logInterface.isInfoEnabled();
- }
-
- /**
- * Determine if this logger is enabled for WARN messages.
- * @return True if the logger is enabled for WARN, false otherwise
- */
- public boolean isWarnEnabled()
- {
- return m_logInterface.isWarnEnabled();
- }
-
- /**
- * Determine if this logger is enabled for ERROR messages.
- * @return True if the logger is enabled for ERROR, false otherwise
- */
- public boolean isErrorEnabled()
- {
- return m_logInterface.isErrorEnabled();
- }
-
- /**
- * Determine if this logger is enabled for FATAL messages.
- * @return True if the logger is enabled for FATAL, false otherwise
- */
- public boolean isFatalEnabled()
- {
- return m_logInterface.isFatalEnabled();
- }
-
-
-
-
- /**************************** Debug Granularity Extension ***************************/
-
- /**
- * Set the debug level, the visibility level, and the facility code.
- *
- * @param dl The finer debugging value.
- * See {@link DebugLevel DebugLevel} for possible values.
- * @param vl The visibility level value.
- * See {@link VisibilityLevel VisibilityLevel} for possible values.
- * @param fl The facility code level value.
- * See {@link FacilityCode FacilityCode} for possible values.
- */
- public void setLevels(long dl, long vl, long fl)
- {
- m_debugLevel = dl;
- m_visLevel = vl;
- m_facLevel = fl;
- }
-
- /**
- * Return the finer debug level.
- *
- * @return The finer debugging level value associated with the logger
- * @see DebugLevel for possible return values.
- */
- public long getDebugLevel()
- {
- return m_debugLevel;
- }
-
- /**
- * Set the debug level as available in the {@link DebugLevel DebugLevel}.
- *
- * @param level The finer debugging value
- * @see DebugLevel for possible values of <code>level</code>.
- */
- public void setDebugLevel(long level)
- {
- m_debugLevel = level;
- }
-
- /**
- * Merge the debug level provided with that currently used by
- * the controller.
- *
- * @param level The finer debugging value
- * @see DebugLevel for possible values of <code>level</code>.
- */
- public void mergeDebugLevel(long level)
- {
- m_debugLevel |= level;
- }
-
- /**
- * Return the visibility level.
- *
- * @return The visibility level value associated with the Logger
- * @see VisibilityLevel for possible return values.
- */
- public long getVisibilityLevel()
- {
- return m_visLevel;
- }
-
- /**
- * Set the visibility level.
- *
- * @param level The visibility level value
- * @see VisibilityLevel for possible values of <code>level</code>.
- */
- public void setVisibilityLevel(long level)
- {
- m_visLevel = level;
- }
-
- /**
- * Merge the visibility level provided with that currently used by the Logger.
- *
- * @param level The visibility level value
- * @see VisibilityLevel for possible values of <code>level</code>.
- */
- public void mergeVisibilityLevel(long level)
- {
- m_visLevel |= level;
- }
-
- /**
- * Return the facility code.
- *
- * @return The facility code value associated with the Logger.
- * @see FacilityCode for possible return values.
- */
- public long getFacilityCode()
- {
- return m_facLevel;
- }
-
- /**
- * Set the facility code.
- *
- * @param level The facility code value
- * @see FacilityCode for possible values of <code>level</code>.
- */
- public void setFacilityCode(long level)
- {
- m_facLevel = level;
- }
-
- /**
- * Merge the debug level provided with that currently used by the Logger.
- *
- * @param level The visibility level value
- * @see FacilityCode for possible values of <code>level</code>.
- */
- public void mergeFacilityCode(long level)
- {
- m_facLevel |= level;
- }
-
- /**
- * Is it allowed to print finer debugging statements?
- *
- * This method returns true when the following is set:
- * <ul>
- * <li>finer debug level = <code>DebugLevel.FULL_DEBUGGING</code>.</li>
- * <li>visibility level = <code>VisibilityLevel.VIS_ALL</code>.</li>
- * <li>facility code = <code>FacilityCode.FAC_ALL</code>.</li>
- * </ul>
- *
- * @return true if the Logger allows full logging
- */
- public boolean debugAllowed()
- {
- return debugAllowed(DebugLevel.FULL_DEBUGGING, VisibilityLevel.VIS_ALL,
- FacilityCode.FAC_ALL);
- }
-
- /**
- * Is it allowed to print finer debugging statements with a given debug level?
- *
- * This method assumes that:
- * <ul>
- * <li>visibility level = <code>VisibilityLevel.VIS_ALL</code>.</li>
- * <li>facility code = <code>FacilityCode.FAC_ALL</code>.</li>
- * </ul>
- *
- * @return true if the Logger allows logging for the finer debugging value <code>dLevel</code>.
- * i.e., dLevel is either equals or greater than the finer debug level assigned to the Logger.
- * @param dLevel The debug finer level to check for.
- */
- public boolean debugAllowed(long dLevel)
- {
- return debugAllowed(dLevel, VisibilityLevel.VIS_ALL, FacilityCode.FAC_ALL);
- }
-
- /**
- * Is it allowed to print finer debugging statements with a given debug level
- * and visibility level?
- *
- * This method assumes that:
- * <ul>
- * <li>facility code = <code>FacilityCode.FAC_ALL</code>.</li>
- * </ul>
- *
- * @return true if the Logger allows logging for the finer debugging value <code>dLevel</code>
- * and visibility level <code>vLevel</code>.
- * i.e., dLevel is equal or greater than the finer debug level assigned to the Logger
- * and vLevel is equal or greater than the visiblity level.
- * @param dLevel The debug finer level to check for.
- * @param vLevel The debug visibilty level to check for.
- */
- public boolean debugAllowed(long dLevel, long vLevel)
- {
- return debugAllowed(dLevel, vLevel, FacilityCode.FAC_ALL);
- }
-
- /**
- * Is it allowed to print finer debugging statements with a given debug level,
- * visibility level and facility code level?
- *
- * @return true if the Logger allows logging for the finer debugging value <code>dLevel</code>,
- * visibility level <code>vLevel</code> and facility code level <code>fLevel</code>.
- * i.e., dLevel is equal or greater than the finer debug level assigned to the Logger
- * and vLevel is equal or greater than the visiblity level
- * and fLevel is equal or greater then the facility code level.
- * @param dLevel The debug finer level to check for.
- * @param vLevel The debug visibilty level to check for.
- * @param fLevel The facility code level to check for.
- */
- public boolean debugAllowed(long dLevel, long vLevel, long fLevel)
- {
- return (((dLevel & m_debugLevel) != 0) &&
- ((vLevel & m_visLevel) != 0) &&
- ((fLevel & m_facLevel) != 0));
- }
-
- /**********************************************************************************************************
- * Finer-Granularity Debug Methods.
- **********************************************************************************************************/
-
-
-
- /**
- * Log a message with the DEBUG Level and with finer granularity. The throwable message
- * is sent to the output only if the specified debug level, visibility level, and facility code
- * match those allowed by the logger.
- * <p>
- * <b>note</b>: this method does not use i18n.
- *
- * @param dl The debug finer level associated with the log message. That is, the logger object allows
- * to log only if the DEBUG level is allowed and dl is either equals or greater the debug level assigned to
- * the logger Object
- * @param vl The visibility level associated with the log message. That is, the logger object allows
- * to log only if the DEBUG level is allowed and vl is either equals or greater the visibility level assigned to
- * the logger Object
- * @param fl The facility code level associated with the log message. That is, the logger object allows
- * to log only if the DEBUG level is allowed and fl is either equals or greater the facility code level assigned to
- * the logger Object
- * @param throwable Throwable associated with the log message
- */
- public void debug(long dl, long vl, long fl, Throwable throwable)
- {
- if (debugAllowed(dl, vl, fl))
- {
- debug(null, null, throwable);
- }
- }
-
- /**
- * Log a message with the DEBUG Level and with finer granularity and with arguments. The debug message
- * is sent to the output only if the specified debug level, visibility level, and facility code
- * match those allowed by the logger.
- * @param dl The debug finer level associated with the log message. That is, the logger object allows
- * to log only if the DEBUG level is allowed and dl is either equals or greater the debug level assigned to
- * the logger Object
- * @param vl The visibility level associated with the log message. That is, the logger object allows
- * to log only if the DEBUG level is allowed and vl is either equals or greater the visibility level assigned to
- * the logger Object
- * @param fl The facility code level associated with the log message. That is, the logger object allows
- * to log only if the DEBUG level is allowed and fl is either equals or greater the facility code level assigned to
- * the logger Object
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- */
- public void debug(long dl, long vl, long fl, String key, Object[] params)
- {
- if (debugAllowed(dl, vl, fl))
- {
- debug(key, params);
- }
- }
-
- /**
- * Log a message with the DEBUG Level and with finer granularity.
- * The debug message is sent to the output only if the specified debug level, visibility level,
- * and facility code match those allowed by the logger.
- * @param dl The debug finer level associated with the log message. That is, the logger object allows
- * to log only if the DEBUG level is allowed and dl is either equals or greater the debug level assigned to
- * the logger Object
- * @param vl The visibility level associated with the log message. That is, the logger object allows
- * to log only if the DEBUG level is allowed and vl is either equals or greater the visibility level assigned to
- * the logger Object
- * @param fl The facility code level associated with the log message. That is, the logger object allows
- * to log only if the DEBUG level is allowed and fl is either equals or greater the facility code level assigned to
- * the logger Object
- * @param key resource bundle key for the message to log
- */
- public void debug(long dl, long vl, long fl, String key)
- {
- if (debugAllowed(dl, vl, fl))
- {
- debug(key);
- }
-
- }
-
- /**
- * Log a message with the DEBUG Level and with finer granularity and throwable message.
- * The debug message is sent to the output only if the specified debug level, visibility level,
- * and facility code match those allowed by the logger.
- * @param dl The debug finer level associated with the log message. That is, the logger object allows
- * to log only if the DEBUG level is allowed and dl is either equals or greater the debug level assigned to
- * the logger Object
- * @param vl The visibility level associated with the log message. That is, the logger object allows
- * to log only if the DEBUG level is allowed and vl is either equals or greater the visibility level assigned to
- * the logger Object
- * @param fl The facility code level associated with the log message. That is, the logger object allows
- * to log only if the DEBUG level is allowed and fl is either equals or greater the facility code level assigned to
- * the logger Object
- * @param key resource bundle key for the message to log
- * @param throwable Throwable associated with the log message
- */
- public void debug(long dl, long vl, long fl, String key, Throwable throwable)
- {
- if (debugAllowed(dl, vl, fl))
- {
- debug(key, throwable);
- }
- }
-
- /**
- * Log a message with the DEBUG Level and with finer granularity, arguments and throwable message.
- * The debug message is sent to the output only if the specified debug level, visibility level,
- * and facility code match those allowed by the logger.
- * @param dl The debug finer level associated with the log message. That is, the logger object allows
- * to log only if the DEBUG level is allowed and dl is either equals or greater the debug level assigned to
- * the logger Object
- * @param vl The visibility level associated with the log message. That is, the logger object allows
- * to log only if the DEBUG level is allowed and vl is either equals or greater the visibility level assigned to
- * the logger Object
- * @param fl The facility code level associated with the log message. That is, the logger object allows
- * to log only if the DEBUG level is allowed and fl is either equals or greater the facility code level assigned to
- * the logger Object
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- * @param throwable Throwable associated with the log message
- */
- public void debug(long dl, long vl, long fl, String key, Object[] params, Throwable throwable)
- {
- if (debugAllowed(dl, vl, fl))
- {
- debug(key, params, throwable);
- }
- }
-
-
- /**********************************************************************************************************/
- /* RESOURCE BUNDLE EVALUATION */
- /**********************************************************************************************************/
-
- /**
- * Obtain a localized message from one of the resource bundles associated
- * with this logger.
- *
- * The user supplied parameter <code>key</code> is replaced by its localized
- * version from the resource bundle.
- *
- * @see #setResourceBundleName
- *
- * @param key unique key to identify an entry in the resource bundle.
- * @return The localised string according to user's locale and available resource bundles. placeholder message
- * if the resource bundle or key cannot be found.
- * //@throws MissingResourceException if the key cannot be found in any of the associated resource bundles.
- */
- public String getString(String key) throws MissingResourceException
- {
- String msg = null;
- try
- {
- msg = getResourceBundleString(key);
- }
- catch (MissingResourceException mre)
- {
- return mre.getLocalizedMessage() + ": [key='" + key + "']";
- }
- return msg;
- }
-
- /**
- * Obtain a localized and parameterized message from one of the resource
- * bundles associated with this logger.
- *
- * First, the user supplied <code>key</code> is searched in the resource
- * bundle. Next, the resulting pattern is formatted using
- * {@link MessageFormat#format(String,Object[])} method with the
- * user supplied object array <code>params</code>.
- *
- * @param key unique key to identify an entry in the resource bundle.
- * @param params parameters to fill placeholders (e.g., {0}, {1}) in the resource bundle string.
- * @return The localised string according to user's locale and available resource bundles. placeholder message
- * if the resource bundle or key cannot be found.
- * //@throws MissingResourceException if the key cannot be found in any of the associated resource bundles.
- */
- public String getString(String key, Object[] params) throws MissingResourceException
- {
- String pattern = null;
- try
- {
- pattern = getResourceBundleString(key);
- }
- catch (MissingResourceException mre)
- {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < params.length; i++)
- {
- sb.append(params[i] + ", ");
- }
- return mre.getLocalizedMessage() + ": [key='" + key + "']" + sb.toString();
- }
- String msg;
- msg = java.text.MessageFormat.format(pattern, params);
- return msg;
- }
-
- /**
- * Obtain a localized message from one of the resource bundles associated
- * with this logger.
- *
- * The user supplied parameter <code>key</code> is replaced by its localized
- * version from the resource bundle <code>base</code>.
- *
- * @see #setResourceBundleName
- *
- * @param base resource bundle name
- * @param key unique key to identify an entry in the resource bundle.
- * @return The localised string according to user's locale and available resource bundles. placeholder message
- * if the resource bundle or key cannot be found.
- * //@throws MissingResourceException if the key cannot be found in any of the associated resource bundles.
- */
- public String getString(String base, String key) throws MissingResourceException
- {
- try
- {
- ResourceBundle rb = PropertyResourceBundle.getBundle(base, Locale.getDefault(), Thread.currentThread().getContextClassLoader());
- String msg = rb.getString(key);
- return msg;
- }
- catch (MissingResourceException mre)
- {
- return mre.getLocalizedMessage() + ": [key='" + key + "']";
- }
- }
-
- /**
- * Obtain a localized and parameterized message from the given resource bundle.
- *
- * First, the user supplied <code>key</code> is searched in the resource
- * bundle. Next, the resulting pattern is formatted using
- * {@link MessageFormat#format(String,Object[])} method with the
- * user supplied object array <code>params</code>.
- *
- * @param base resource bundle name
- * @param key unique key to identify an entry in the resource bundle.
- * @param params parameters to fill placeholders (e.g., {0}, {1}) in the resource bundle string.
- * @return The localised string according to user's locale and available resource bundles. placeholder message
- * if the resource bundle or key cannot be found.
- * //@throws MissingResourceException if the key cannot be found in any of the associated resource bundles.
- */
- public String getString(String base, String key, Object[] params) throws MissingResourceException
- {
- try
- {
- ResourceBundle rb = PropertyResourceBundle.getBundle(base, Locale.getDefault(), Thread.currentThread().getContextClassLoader());
- String pattern = rb.getString(key);
- String msg = java.text.MessageFormat.format(pattern, params);
- return msg;
- }
- catch (MissingResourceException mre)
- {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < params.length; i++)
- {
- sb.append(params[i] + ", ");
- }
- return mre.getLocalizedMessage() + ": [key='" + key + "']" + sb.toString();
- }
- }
-
- /**
- *
- * @param key
- * @return the resource bundle String
- * @throws MissingResourceException
- */
- protected synchronized String getResourceBundleString(String key) throws MissingResourceException
- {
- String resource = null;
- if (m_defaultResourceBundle == null)
- {
- throw new MissingResourceException("no default resource bundle set for this logger", null, null);
- }
- else
- {
- try
- {
- resource = m_defaultResourceBundle.getString(key);
- }
- // this exception will occur if no resource for the given key can be found.
- catch (MissingResourceException mre)
- {
- // if no extra res bundles are available, that's it. bail out!
- if (m_extraResourceBundles == null)
- {
- throw mre;
- }
- else
- {
- for (int i = 0; i < m_extraResourceBundles.length; i++)
- {
- try
- {
- resource = m_extraResourceBundles[i].getString(key);
- }
- catch (MissingResourceException mre2)
- {
- mre = mre2;
- }
- }
- // if no resource for the given key could be found in any of the
- // resource bundles, throw an exception.
- if (resource == null)
- {
- throw mre;
- }
- }
- }
- }
- return resource;
- }
-}
Deleted: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/AbstractLogInterface.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/AbstractLogInterface.java 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/AbstractLogInterface.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -1,104 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-/*
- * AbstractLogInterface.java
- *
- * Copyright (c) 2003 Arjuna Technologies Ltd.
- * Arjuna Technologies Ltd. Confidential
- *
- * Created on Aug 6, 2003, 5:47:00 PM by Thomas Rischbeck
- */
-package com.arjuna.common.internal.util.logging;
-
-/**
- * JavaDoc
- *
- * @author Thomas Rischbeck <thomas.rischbeck at arjuna.com>
- * @version $Revision: 2342 $ $Date: 2006-03-30 14:06:17 +0100 (Thu, 30 Mar 2006) $
- * @since clf-2.0
- */
-public interface AbstractLogInterface
-{
- /**
- * Is DEBUG logging currently enabled?
- *
- * Call this method to prevent having to perform expensive operations
- * (for example, <code>String</code> concatination)
- * when the log level is more than DEBUG.
- *
- * @return True if the logger is enabled for DEBUG, false otherwise
- */
- boolean isDebugEnabled();
-
- /**
- * Is INFO logging currently enabled?
- *
- * Call this method to prevent having to perform expensive operations
- * (for example, <code>String</code> concatination)
- * when the log level is more than INFO.
- *
- * @return True if the logger is enabled for INFO, false otherwise
- */
- boolean isInfoEnabled();
-
- /**
- * Is WARN logging currently enabled?
- *
- * Call this method to prevent having to perform expensive operations
- * (for example, <code>String</code> concatination)
- * when the log level is more than WARN.
- *
- * @return True if the logger is enabled for WARN, false otherwise
- */
- boolean isWarnEnabled();
-
- /**
- * Is ERROR logging currently enabled?
- *
- * Call this method to prevent having to perform expensive operations
- * (for example, <code>String</code> concatination)
- * when the log level is more than ERROR.
- *
- * @return True if the logger is enabled for ERROR, false otherwise
- */
- boolean isErrorEnabled();
-
- /**
- * Is FATAL logging currently enabled?
- *
- * Call this method to prevent having to perform expensive operations
- * (for example, <code>String</code> concatination)
- * when the log level is more than FATAL.
- *
- * @return True if the logger is enabled for FATAL, false otherwise
- */
- boolean isFatalEnabled();
-
- /**
- * Is TRACE logging currently enabled?
- *
- * Call this method to prevent having to perform expensive operations
- * (for example, <code>String</code> concatination)
- * when the log level is more than TRACE.
- */
- public boolean isTraceEnabled();
-
-}
Deleted: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/DefaultLog.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/DefaultLog.java 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/DefaultLog.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -1,615 +0,0 @@
-/*
- * This file has been copied from the Apache Commons Logging project
- * release version 1.1.0 and then modified.
- * It was formerly called org.apache.commons.logging.impl.SimpleLog.
- *
- * Apart from the package and class name changes, the modifications
- * relate to configuration properties and use of a file rather than
- * System.out for default logging.
- */
-
-
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.apache.commons.logging.impl; // apache version
-package com.arjuna.common.internal.util.logging; // Red Hat modification
-
-import java.io.Serializable;
-import java.io.FileOutputStream;
-import java.io.PrintStream;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Properties;
-
-
-/**
- * <p>Simple implementation of Log that sends all enabled log messages,
- * for all defined loggers, to System.err. The following system properties
- * are supported to configure the behavior of this logger:</p>
- * <ul>
- * <li><code>org.apache.commons.logging.simplelog.defaultlog</code> -
- * Default logging detail level for all instances of SimpleLog.
- * Must be one of ("trace", "debug", "info", "warn", "error", or "fatal").
- * If not specified, defaults to "info". </li>
- * <li><code>org.apache.commons.logging.simplelog.log.xxxxx</code> -
- * Logging detail level for a SimpleLog instance named "xxxxx".
- * Must be one of ("trace", "debug", "info", "warn", "error", or "fatal").
- * If not specified, the default logging detail level is used.</li>
- * <li><code>org.apache.commons.logging.simplelog.showlogname</code> -
- * Set to <code>true</code> if you want the Log instance name to be
- * included in output messages. Defaults to <code>false</code>.</li>
- * <li><code>org.apache.commons.logging.simplelog.showShortLogname</code> -
- * Set to <code>true</code> if you want the last component of the name to be
- * included in output messages. Defaults to <code>true</code>.</li>
- * <li><code>org.apache.commons.logging.simplelog.showdatetime</code> -
- * Set to <code>true</code> if you want the current date and time
- * to be included in output messages. Default is <code>false</code>.</li>
- * <li><code>org.apache.commons.logging.simplelog.dateTimeFormat</code> -
- * The date and time format to be used in the output messages.
- * The pattern describing the date and time format is the same that is
- * used in <code>java.text.SimpleDateFormat</code>. If the format is not
- * specified or is invalid, the default format is used.
- * The default format is <code>yyyy/MM/dd HH:mm:ss:SSS zzz</code>.</li>
- * </ul>
- *
- * <p>In addition to looking for system properties with the names specified
- * above, this implementation also checks for a class loader resource named
- * <code>"simplelog.properties"</code>, and includes any matching definitions
- * from this resource (if it exists).</p>
- *
- * @author <a href="mailto:sanders at apache.org">Scott Sanders</a>
- * @author Rod Waldhoff
- * @author Robert Burrell Donkin
- *
- * @version (apache version) Id: SimpleLog.java 399221 2006-05-03 09:20:24Z dennisl
- */
-public class DefaultLog implements Serializable, LogInterface {
-
-
- // ------------------------------------------------------- Class Attributes
-
- /** All system properties used by <code>SimpleLog</code> start with this */
- //static protected final String systemPrefix =
- // "org.apache.commons.logging.simplelog.";
-
- static final String LOG_ENABLED_PROPERTY = "com.arjuna.common.util.logging.default";
- static final String LOG_LEVEL = "com.arjuna.common.util.logging.default.level";
- static final String SHOW_LOG_NAME = "com.arjuna.common.util.logging.default.showLogName";
- static final String SHOW_SHORT_LOG_NAME = "com.arjuna.common.util.logging.default.showShortLogName";
- static final String SHOW_DATE = "com.arjuna.common.util.logging.default.showDate";
- static final String LOG_FILE = "com.arjuna.common.util.logging.default.logFile";
- static final String LOG_FILE_APPEND = "com.arjuna.common.util.logging.default.logFileAppend";
- static final String LOG_FILE_DEFAULT = "error.log";
-
- /** Properties loaded from simplelog.properties */
- static protected final Properties simpleLogProps = new Properties();
-
- /** The default format to use when formating dates */
- static protected final String DEFAULT_DATE_TIME_FORMAT =
- "yyyy/MM/dd HH:mm:ss:SSS zzz";
-
- /** Include the instance name in the log message? */
- static protected boolean showLogName = false;
- /** Include the short name ( last component ) of the logger in the log
- * message. Defaults to true - otherwise we'll be lost in a flood of
- * messages without knowing who sends them.
- */
- static protected boolean showShortName = true;
- /** Include the current time in the log message */
- static protected boolean showDateTime = true;
- /** The date and time format to use in the log message */
- static protected String dateTimeFormat = DEFAULT_DATE_TIME_FORMAT;
- /** Used to format times */
- static protected DateFormat dateFormatter = null;
-
- static PrintStream defaultLogFile = null;
-
- // ---------------------------------------------------- Log Level Constants
-
-
- /** "Trace" level logging. */
- public static final int LOG_LEVEL_TRACE = 1;
- /** "Debug" level logging. */
- public static final int LOG_LEVEL_DEBUG = 2;
- /** "Info" level logging. */
- public static final int LOG_LEVEL_INFO = 3;
- /** "Warn" level logging. */
- public static final int LOG_LEVEL_WARN = 4;
- /** "Error" level logging. */
- public static final int LOG_LEVEL_ERROR = 5;
- /** "Fatal" level logging. */
- public static final int LOG_LEVEL_FATAL = 6;
-
- /** Enable all logging levels */
- public static final int LOG_LEVEL_ALL = (LOG_LEVEL_TRACE - 1);
-
- /** Enable no logging levels */
- public static final int LOG_LEVEL_OFF = (LOG_LEVEL_FATAL + 1);
-
- // ------------------------------------------------------------ Initializer
-
- // Initialize class attributes.
- // Load properties file, if found.
- // Override with system properties.
- static {
-
- showLogName = commonPropertyManager.getDefaultLogEnvironmentBean().isShowLogName();
- showShortName = commonPropertyManager.getDefaultLogEnvironmentBean().isShowShortLogName();
- showDateTime = commonPropertyManager.getDefaultLogEnvironmentBean().isShowDate();
- dateFormatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss:SSS zzz");
-
- String fileName = commonPropertyManager.getDefaultLogEnvironmentBean().getLogFile();
- boolean fileAppend = commonPropertyManager.getDefaultLogEnvironmentBean().isLogFileAppend();
- try {
- FileOutputStream fOut = new FileOutputStream(fileName, fileAppend);
- defaultLogFile = new PrintStream(fOut, true);
- defaultLogFile.println();
- defaultLogFile.println();
- defaultLogFile.println("---------------------------------------------------------------");
- defaultLogFile.println("DEFAULT LOG, started " + dateFormatter.format(new Date()));
- defaultLogFile.println("---------------------------------------------------------------");
- }
- catch (Exception e)
- {
- System.err.println("cannot set up default log for error messages to file " + fileName + ": " + e.getMessage());
- e.printStackTrace();
- }
- }
-
-
- // ------------------------------------------------------------- Attributes
-
- /** The name of this simple log instance */
- protected String logName = null;
- /** The current log level */
- protected int currentLogLevel;
- /** The short name of this simple log instance */
- private String shortLogName = null;
-
-
- // ------------------------------------------------------------ Constructor
-
- /**
- * Construct a simple log with given name.
- *
- * @param name log name
- */
- public DefaultLog(String name) {
-
- logName = name;
-
- // Set initial log level
- // Used to be: set default log level to ERROR
- // IMHO it should be lower, but at least info ( costin ).
- setLevel(DefaultLog.LOG_LEVEL_INFO);
-
- // Set log level from properties
- String lvl = commonPropertyManager.getDefaultLogEnvironmentBean().getDefaultLevel();
- if(null == lvl) {
- lvl = System.getProperty(LOG_LEVEL + "info");
- }
-
- if("all".equalsIgnoreCase(lvl)) {
- setLevel(DefaultLog.LOG_LEVEL_ALL);
- } else if("trace".equalsIgnoreCase(lvl)) {
- setLevel(DefaultLog.LOG_LEVEL_TRACE);
- } else if("debug".equalsIgnoreCase(lvl)) {
- setLevel(DefaultLog.LOG_LEVEL_DEBUG);
- } else if("info".equalsIgnoreCase(lvl)) {
- setLevel(DefaultLog.LOG_LEVEL_INFO);
- } else if("warn".equalsIgnoreCase(lvl)) {
- setLevel(DefaultLog.LOG_LEVEL_WARN);
- } else if("error".equalsIgnoreCase(lvl)) {
- setLevel(DefaultLog.LOG_LEVEL_ERROR);
- } else if("fatal".equalsIgnoreCase(lvl)) {
- setLevel(DefaultLog.LOG_LEVEL_FATAL);
- } else if("off".equalsIgnoreCase(lvl)) {
- setLevel(DefaultLog.LOG_LEVEL_OFF);
- }
-
- }
-
-
- // -------------------------------------------------------- Properties
-
- /**
- * <p> Set logging level. </p>
- *
- * @param currentLogLevel new logging level
- */
- public void setLevel(int currentLogLevel) {
-
- this.currentLogLevel = currentLogLevel;
-
- }
-
-
- /**
- * <p> Get logging level. </p>
- * @return the current logging level
- */
- public int getLevel() {
-
- return currentLogLevel;
- }
-
-
- // -------------------------------------------------------- Logging Methods
-
-
- /**
- * <p> Do the actual logging.
- * This method assembles the message
- * and then calls <code>write()</code> to cause it to be written.</p>
- *
- * @param type One of the LOG_LEVEL_XXX constants defining the log level
- * @param message The message itself (typically a String)
- * @param t The exception whose stack trace should be logged
- */
- protected void log(int type, Object message, Throwable t) {
- // Use a string buffer for better performance
- StringBuffer buf = new StringBuffer();
-
- // Append date-time if so configured
- if(showDateTime) {
- buf.append(dateFormatter.format(new Date()));
- buf.append(" ");
- }
-
- // Append a readable representation of the log level
- switch(type) {
- case DefaultLog.LOG_LEVEL_TRACE: buf.append("[TRACE] "); break;
- case DefaultLog.LOG_LEVEL_DEBUG: buf.append("[DEBUG] "); break;
- case DefaultLog.LOG_LEVEL_INFO: buf.append("[INFO] "); break;
- case DefaultLog.LOG_LEVEL_WARN: buf.append("[WARN] "); break;
- case DefaultLog.LOG_LEVEL_ERROR: buf.append("[ERROR] "); break;
- case DefaultLog.LOG_LEVEL_FATAL: buf.append("[FATAL] "); break;
- }
-
- // Append the name of the log instance if so configured
- if( showShortName) {
- if( shortLogName==null ) {
- // Cut all but the last component of the name for both styles
- shortLogName = logName.substring(logName.lastIndexOf(".") + 1);
- shortLogName =
- shortLogName.substring(shortLogName.lastIndexOf("/") + 1);
- }
- buf.append(String.valueOf(shortLogName)).append(" - ");
- } else if(showLogName) {
- buf.append(String.valueOf(logName)).append(" - ");
- }
-
- // Append the message
- buf.append(String.valueOf(message));
-
- // Append stack trace if not null
- if(t != null) {
- buf.append(" <");
- buf.append(t.toString());
- buf.append(">");
-
- java.io.StringWriter sw= new java.io.StringWriter(1024);
- java.io.PrintWriter pw= new java.io.PrintWriter(sw);
- t.printStackTrace(pw);
- pw.close();
- buf.append(sw.toString());
- }
-
- // Print to the appropriate destination
- write(buf);
-
- }
-
-
- /**
- * <p>Write the content of the message accumulated in the specified
- * <code>StringBuffer</code> to the appropriate output destination. The
- * default implementation writes to <code>System.err</code>.</p>
- *
- * @param buffer A <code>StringBuffer</code> containing the accumulated
- * text to be logged
- */
- protected void write(StringBuffer buffer) {
-
- // print to log file.
- defaultLogFile.println(buffer.toString());
-
- }
-
-
- /**
- * Is the given log level currently enabled?
- *
- * @param logLevel is this level enabled?
- * @return true is enabled, false otherwise
- */
- protected boolean isLevelEnabled(int logLevel) {
- // log level are numerically ordered so can use simple numeric
- // comparison
- return (logLevel >= currentLogLevel);
- }
-
-
- // -------------------------------------------------------- Log Implementation
-
-
- /**
- * Logs a message with
- * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_DEBUG</code>.
- *
- * @param message to log
- * @see org.apache.commons.logging.Log#debug(Object)
- */
- public final void debug(Object message) {
-
- if (isLevelEnabled(DefaultLog.LOG_LEVEL_DEBUG)) {
- log(DefaultLog.LOG_LEVEL_DEBUG, message, null);
- }
- }
-
-
- /**
- * Logs a message with
- * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_DEBUG</code>.
- *
- * @param message to log
- * @param t log this cause
- * @see org.apache.commons.logging.Log#debug(Object, Throwable)
- */
- public final void debug(Object message, Throwable t) {
-
- if (isLevelEnabled(DefaultLog.LOG_LEVEL_DEBUG)) {
- log(DefaultLog.LOG_LEVEL_DEBUG, message, t);
- }
- }
-
-
- /**
- * Logs a message with
- * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_TRACE</code>.
- *
- * @param message to log
- * @see org.apache.commons.logging.Log#trace(Object)
- */
- public final void trace(Object message) {
-
- if (isLevelEnabled(DefaultLog.LOG_LEVEL_TRACE)) {
- log(DefaultLog.LOG_LEVEL_TRACE, message, null);
- }
- }
-
-
- /**
- * Logs a message with
- * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_TRACE</code>.
- *
- * @param message to log
- * @param t log this cause
- * @see org.apache.commons.logging.Log#trace(Object, Throwable)
- */
- public final void trace(Object message, Throwable t) {
-
- if (isLevelEnabled(DefaultLog.LOG_LEVEL_TRACE)) {
- log(DefaultLog.LOG_LEVEL_TRACE, message, t);
- }
- }
-
-
- /**
- * Logs a message with
- * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_INFO</code>.
- *
- * @param message to log
- * @see org.apache.commons.logging.Log#info(Object)
- */
- public final void info(Object message) {
-
- if (isLevelEnabled(DefaultLog.LOG_LEVEL_INFO)) {
- log(DefaultLog.LOG_LEVEL_INFO,message,null);
- }
- }
-
-
- /**
- * Logs a message with
- * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_INFO</code>.
- *
- * @param message to log
- * @param t log this cause
- * @see org.apache.commons.logging.Log#info(Object, Throwable)
- */
- public final void info(Object message, Throwable t) {
-
- if (isLevelEnabled(DefaultLog.LOG_LEVEL_INFO)) {
- log(DefaultLog.LOG_LEVEL_INFO, message, t);
- }
- }
-
-
- /**
- * Logs a message with
- * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_WARN</code>.
- *
- * @param message to log
- * @see org.apache.commons.logging.Log#warn(Object)
- */
- public final void warn(Object message) {
-
- if (isLevelEnabled(DefaultLog.LOG_LEVEL_WARN)) {
- log(DefaultLog.LOG_LEVEL_WARN, message, null);
- }
- }
-
-
- /**
- * Logs a message with
- * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_WARN</code>.
- *
- * @param message to log
- * @param t log this cause
- * @see org.apache.commons.logging.Log#warn(Object, Throwable)
- */
- public final void warn(Object message, Throwable t) {
-
- if (isLevelEnabled(DefaultLog.LOG_LEVEL_WARN)) {
- log(DefaultLog.LOG_LEVEL_WARN, message, t);
- }
- }
-
-
- /**
- * Logs a message with
- * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_ERROR</code>.
- *
- * @param message to log
- * @see org.apache.commons.logging.Log#error(Object)
- */
- public final void error(Object message) {
-
- if (isLevelEnabled(DefaultLog.LOG_LEVEL_ERROR)) {
- log(DefaultLog.LOG_LEVEL_ERROR, message, null);
- }
- }
-
-
- /**
- * Logs a message with
- * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_ERROR</code>.
- *
- * @param message to log
- * @param t log this cause
- * @see org.apache.commons.logging.Log#error(Object, Throwable)
- */
- public final void error(Object message, Throwable t) {
-
- if (isLevelEnabled(DefaultLog.LOG_LEVEL_ERROR)) {
- log(DefaultLog.LOG_LEVEL_ERROR, message, t);
- }
- }
-
-
- /**
- * Log a message with
- * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_FATAL</code>.
- *
- * @param message to log
- * @see org.apache.commons.logging.Log#fatal(Object)
- */
- public final void fatal(Object message) {
-
- if (isLevelEnabled(DefaultLog.LOG_LEVEL_FATAL)) {
- log(DefaultLog.LOG_LEVEL_FATAL, message, null);
- }
- }
-
-
- /**
- * Logs a message with
- * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_FATAL</code>.
- *
- * @param message to log
- * @param t log this cause
- * @see org.apache.commons.logging.Log#fatal(Object, Throwable)
- */
- public final void fatal(Object message, Throwable t) {
-
- if (isLevelEnabled(DefaultLog.LOG_LEVEL_FATAL)) {
- log(DefaultLog.LOG_LEVEL_FATAL, message, t);
- }
- }
-
-
- /**
- * <p> Are debug messages currently enabled? </p>
- *
- * <p> This allows expensive operations such as <code>String</code>
- * concatenation to be avoided when the message will be ignored by the
- * logger. </p>
- */
- public final boolean isDebugEnabled() {
-
- return isLevelEnabled(DefaultLog.LOG_LEVEL_DEBUG);
- }
-
-
- /**
- * <p> Are error messages currently enabled? </p>
- *
- * <p> This allows expensive operations such as <code>String</code>
- * concatenation to be avoided when the message will be ignored by the
- * logger. </p>
- */
- public final boolean isErrorEnabled() {
-
- return isLevelEnabled(DefaultLog.LOG_LEVEL_ERROR);
- }
-
-
- /**
- * <p> Are fatal messages currently enabled? </p>
- *
- * <p> This allows expensive operations such as <code>String</code>
- * concatenation to be avoided when the message will be ignored by the
- * logger. </p>
- */
- public final boolean isFatalEnabled() {
-
- return isLevelEnabled(DefaultLog.LOG_LEVEL_FATAL);
- }
-
-
- /**
- * <p> Are info messages currently enabled? </p>
- *
- * <p> This allows expensive operations such as <code>String</code>
- * concatenation to be avoided when the message will be ignored by the
- * logger. </p>
- */
- public final boolean isInfoEnabled() {
-
- return isLevelEnabled(DefaultLog.LOG_LEVEL_INFO);
- }
-
-
- /**
- * <p> Are trace messages currently enabled? </p>
- *
- * <p> This allows expensive operations such as <code>String</code>
- * concatenation to be avoided when the message will be ignored by the
- * logger. </p>
- */
- public final boolean isTraceEnabled() {
-
- return isLevelEnabled(DefaultLog.LOG_LEVEL_TRACE);
- }
-
-
- /**
- * <p> Are warn messages currently enabled? </p>
- *
- * <p> This allows expensive operations such as <code>String</code>
- * concatenation to be avoided when the message will be ignored by the
- * logger. </p>
- */
- public final boolean isWarnEnabled() {
-
- return isLevelEnabled(DefaultLog.LOG_LEVEL_WARN);
- }
-}
-
Deleted: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/DefaultLogEnvironmentBean.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/DefaultLogEnvironmentBean.java 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/DefaultLogEnvironmentBean.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -1,181 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2009,
- * @author JBoss, a division of Red Hat.
- */
-package com.arjuna.common.internal.util.logging;
-
-import com.arjuna.common.internal.util.propertyservice.PropertyPrefix;
-
-/**
- * A JavaBean containing configuration properties for the default log system.
- *
- * @author Jonathan Halliday (jonathan.halliday at redhat.com)
- */
- at PropertyPrefix(prefix = "com.arjuna.common.util.logging.default.")
-public class DefaultLogEnvironmentBean
-{
- private volatile boolean showLogName = false;
- private volatile boolean showShortLogName = true;
- private volatile boolean showDate = true;
- private volatile boolean logFileAppend = true;
-
- private volatile String defaultLevel = "info";
-
- private volatile String logFile = "error.log";
-
-
- /**
- * Returns true if the log output should contain the log name element.
- *
- * Default: false
- * Equivalent deprecated property: com.arjuna.common.util.logging.default.showLogName
- *
- * @return true if the log name should appear in the log output, false otherwise.
- */
- public boolean isShowLogName()
- {
- return showLogName;
- }
-
- /**
- * Enables the use of the log name element in log output.
- *
- * @param showLogName true if the log name should appear in the log output, false otherwise.
- */
- public void setShowLogName(boolean showLogName)
- {
- this.showLogName = showLogName;
- }
-
- /**
- * Returns true if the log output should contain the short form log name element.
- *
- * Default: true
- * Equivalent deprecated property: com.arjuna.common.util.logging.default.showShortLogName
- *
- * @return true if the short log name should appear in the log output, false otherwise.
- */
- public boolean isShowShortLogName()
- {
- return showShortLogName;
- }
-
- /**
- * Enables use of the short log name element in log output.
- *
- * @param showShortLogName true if the log name should appear in the log output, false otherwise.
- */
- public void setShowShortLogName(boolean showShortLogName)
- {
- this.showShortLogName = showShortLogName;
- }
-
- /**
- * Returns true if the log output should contain the date/time element.
- *
- * Default: true
- * Equivalent deprecated property: com.arjuna.common.util.logging.default.showDate
- *
- * @return true if the date/time should appear in the log output, false otherwise.
- */
- public boolean isShowDate()
- {
- return showDate;
- }
-
- /**
- * Enables use of the date/time element in log output.
- *
- * @param showDate true if the date/time should appear in log output, false otherwise.
- */
- public void setShowDate(boolean showDate)
- {
- this.showDate = showDate;
- }
-
- /**
- * Returns true if the log file should be appended to.
- *
- * Default: true
- * Equivalent deprecated property: com.arjuna.common.util.logging.default.logFileAppend
- *
- * @return true if append behaviour is required, false for overwrite behaviour.
- */
- public boolean isLogFileAppend()
- {
- return logFileAppend;
- }
-
- /**
- * Enables appending to an existing log file rather than overwiting it.
- *
- * @param logFileAppend true for appending, false otherwise.
- */
- public void setLogFileAppend(boolean logFileAppend)
- {
- this.logFileAppend = logFileAppend;
- }
-
- /**
- * Returns the threshold level for logging.
- *
- * Default: "info"
- * Equivalent deprecated property: com.arjuna.common.util.logging.default.defaultLevel
- *
- * @return the default threshold logging level.
- */
- public String getDefaultLevel()
- {
- return defaultLevel;
- }
-
- /**
- * Sets the default log threshold.
- * Valid values (in order) are: all, trace, debug, info, warn, error, fatal, off
- *
- * @param defaultLevel the default log threshold.
- */
- public void setDefaultLevel(String defaultLevel)
- {
- this.defaultLevel = defaultLevel;
- }
-
- /**
- * Returns the name of the log file to use.
- *
- * Default: "error.log"
- * Equivalent deprecated property: com.arjuna.common.util.logging.default.logFile
- *
- * @return the name of the file to which the log statements will be written.
- */
- public String getLogFile()
- {
- return logFile;
- }
-
- /**
- * Sets the name of the log file to write output to.
- *
- * @param logFile the filename, relative or absolute.
- */
- public void setLogFile(String logFile)
- {
- this.logFile = logFile;
- }
-}
Modified: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LogFactoryInterface.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LogFactoryInterface.java 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LogFactoryInterface.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -33,18 +33,8 @@
/**
* Interface that gives a handle to the underlying log subsystem's log factory.
*
- * The following log subsystems are supported:
- * <ul>
- * <li>Jakarta Commons Logging (JCL). JCL can delegate to various other logging subsystems, such as:
- * <ul>
- * <li>log4j</li>
- * <li>JDK 1.4 logging</li>
- * <li>Windows NT syslog</li>
- * <li>console</li>
- * </ul>
- * </li>
- * <li>.net logging. (must be JDK 1.1 compliant for compilation by the Microsoft compiler)</li>
- * </ul>
+ * We provide an implementation for Jakarta Commons Logging (JCL) and a simple built-in one.
+ * Users may provide additional implementations, see LoggingEnvironmentBean.logFactory for config.
*
* @author Thomas Rischbeck <thomas.rischbeck at arjuna.com>
* @version $Revision: 2342 $ $Date: 2006-03-30 14:06:17 +0100 (Thu, 30 Mar 2006) $
@@ -52,28 +42,15 @@
*/
public interface LogFactoryInterface
{
-
/**
- * Convenience method to return a named logger, without the application
- * having to care about factories.
+ * Method to return a named logger.
*
- * @param clazz Class for which a log name will be derived
- *
- * @exception LogConfigurationException if a suitable <code>Log</code>
- * instance cannot be returned
- */
- public AbstractLogInterface getLog(Class clazz);
-
- /**
- * Convenience method to return a named logger, without the application
- * having to care about factories.
- *
* @param name Logical name of the <code>Log</code> instance to be
* returned (the meaning of this name is only known to the underlying
* logging implementation that is being wrapped)
*
- * @exception LogConfigurationException if a suitable <code>Log</code>
+ * @exception LogConfigurationException if a suitable <code>LogInterface</code>
* instance cannot be returned
*/
- public AbstractLogInterface getLog(String name) throws LogConfigurationException;
+ public LogInterface getLog(String name) throws LogConfigurationException;
}
Deleted: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LogImpl.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LogImpl.java 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LogImpl.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -1,862 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-/*
-* LogImpl.java
-*
-* Copyright (c) 2003 Arjuna Technologies Ltd.
-* Arjuna Technologies Ltd. Confidential
-*
-* Created on Jun 30, 2003, 12:48:49 PM by Thomas Rischbeck
-*/
-package com.arjuna.common.internal.util.logging;
-
-import com.arjuna.common.util.logging.*;
-
-/**
- * Implementation of the Log interface without i18n support.
- *
- * Most log subsystems do not provide i18n, therefore we do resource
- * bundle evaluation in this class. An exception is the CSF logging.
- *
- * @author Thomas Rischbeck <thomas.rischbeck at arjuna.com>
- * @version $Revision: 2342 $ $Date: 2006-03-30 14:06:17 +0100 (Thu, 30 Mar 2006) $
- * @since clf-2.0
- */
-public class LogImpl extends AbstractLogImpl implements Logi18n
-{
-
- /**
- * Interface to the log subsystem to use
- */
- private LogInterface m_logInterface = null;
-
- /**
- * a default file-based logger for a certain severity level.
- * this can be configured to always be on, independt of the underlying
- * log framwork configured. this is controlled through teh property
- * com.arjuna.common.logging.default=true/false (default)
- */
- private LogInterface m_defaultLog = null;
-
- /**
- * indicates whehter the default log is set or not.
- */
- private boolean defaultLogSet = false;
-
-
- /**
- * constructor
- *
- * @param logInterface
- */
- public LogImpl(LogInterface logInterface)
- {
- super(logInterface);
- m_logInterface = logInterface;
- setupDefaultLog("default");
- }
-
- /**
- * constructor
- *
- * @param logInterface
- * @param resBundle bundle used for this logger (if a resource bundle is used per logger)
- */
- public LogImpl(LogInterface logInterface, String resBundle)
- {
- super(logInterface, resBundle);
- m_logInterface = logInterface;
- setupDefaultLog(resBundle);
- }
-
- private void setupDefaultLog(String name)
- {
- if (commonPropertyManager.getLoggingEnvironmentBean().isUseDefaultLog())
- {
- m_defaultLog = new DefaultLog(name);
- defaultLogSet = true;
- }
- }
-
-
- /**
- * Determine if this logger is enabled for DEBUG messages.
- * @return True if the logger is enabled for DEBUG, false otherwise
- */
- public boolean isDebugEnabled()
- {
- if (defaultLogSet)
- {
- return m_logInterface.isDebugEnabled() || m_defaultLog.isDebugEnabled();
- }
- return m_logInterface.isDebugEnabled();
- }
-
- /**
- * Determine if this logger is enabled for INFO messages.
- * @return True if the logger is enabled for INFO, false otherwise
- */
- public boolean isInfoEnabled()
- {
- if (defaultLogSet)
- {
- return m_logInterface.isInfoEnabled() || m_defaultLog.isInfoEnabled();
- }
- return m_logInterface.isInfoEnabled();
- }
-
- /**
- * Determine if this logger is enabled for WARN messages.
- * @return True if the logger is enabled for WARN, false otherwise
- */
- public boolean isWarnEnabled()
- {
- if (defaultLogSet)
- {
- return m_logInterface.isWarnEnabled() || m_defaultLog.isWarnEnabled();
- }
- return m_logInterface.isWarnEnabled();
- }
-
- /**
- * Determine if this logger is enabled for ERROR messages.
- * @return True if the logger is enabled for ERROR, false otherwise
- */
- public boolean isErrorEnabled()
- {
- if (defaultLogSet)
- {
- return m_logInterface.isErrorEnabled() || m_defaultLog.isErrorEnabled();
- }
- return m_logInterface.isErrorEnabled();
- }
-
- /**
- * Determine if this logger is enabled for FATAL messages.
- * @return True if the logger is enabled for FATAL, false otherwise
- */
- public boolean isFatalEnabled()
- {
- if (defaultLogSet)
- {
- return m_logInterface.isFatalEnabled() || m_defaultLog.isFatalEnabled();
- }
- return m_logInterface.isFatalEnabled();
- }
-
-
- /**
- * Log a message with DEBUG Level
- *
- * @param key resource bundle key for the message to log
- *
- * @deprecated use debug (String key, null) instead
- */
- public void debug(String key)
- {
- if (!isDebugEnabled()) return;
- String message = evalResourceBundle(key);
- m_logInterface.debug(message);
- if (defaultLogSet)
- m_defaultLog.debug(message);
- }
-
- /**
- * Log a throwable message with DEBUG Level
- *
- * @param throwable The Throwable to log
- */
- public void debug(Throwable throwable)
- {
- if (!isDebugEnabled()) return;
- String message = throwable.getLocalizedMessage();
- m_logInterface.debug(message, throwable);
- if (defaultLogSet)
- m_defaultLog.debug(message, throwable);
- }
-
- /**
- * Log a message with the DEBUG Level and with a throwable arguments
- * @param key resource bundle key for the message to log
- * @param throwable The Throwable to log
- */
- public void debug(String key, Throwable throwable)
- {
- if (!isDebugEnabled()) return;
- String message = evalResourceBundle(key);
- m_logInterface.debug(message, throwable);
- if (defaultLogSet)
- m_defaultLog.debug(message, throwable);
- }
-
- /**
- * Log a message with DEBUG Level and with arguments
- *
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- */
- public void debug(String key, Object[] params)
- {
- if (!isDebugEnabled()) return;
- String message = evalResourceBundle(key, params);
- m_logInterface.debug(message);
- if (defaultLogSet)
- m_defaultLog.debug(message);
- }
-
- /**
- * Log a message with DEBUG Level, with arguments and with a throwable arguments
- *
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- * @param throwable The Throwable to log
- */
- public void debug(String key, Object[] params, Throwable throwable)
- {
- if (!isDebugEnabled()) return;
- String message = evalResourceBundle(key, params);
- m_logInterface.debug(message, throwable);
- if (defaultLogSet)
- m_defaultLog.debug(message, throwable);
- }
-
- /**
- * Log a message with INFO Level
- *
- * @param key resource bundle key for the message to log
- *
- * @deprecated use info (String key, null) instead
- */
- public void info(String key)
- {
- if (!isInfoEnabled()) return;
- String message = evalResourceBundle(key);
- m_logInterface.info(message);
- if (defaultLogSet)
- m_defaultLog.info(message);
- }
-
- /**
- * Log a throwable message with te INFO Level
- * @param throwable The Throwable to log
- */
- public void info(Throwable throwable)
- {
- if (!isInfoEnabled()) return;
- String message = throwable.getLocalizedMessage();
- m_logInterface.info(message, throwable);
- if (defaultLogSet)
- m_defaultLog.info(message, throwable);
- }
-
- /**
- * Log a message with the INFO Level and with a throwable arguments
- * @param key resource bundle key for the message to log
- * @param throwable Throwable associated to the logging message
- */
- public void info(String key, Throwable throwable)
- {
- if (!isInfoEnabled()) return;
- String message = evalResourceBundle(key);
- m_logInterface.info(message, throwable);
- if (defaultLogSet)
- m_defaultLog.info(message, throwable);
- }
-
- /**
- * Log a message with the INFO Level and with arguments
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- */
- public void info(String key, Object[] params)
- {
- if (!isInfoEnabled()) return;
- String message = evalResourceBundle(key, params);
- m_logInterface.info(message);
- if (defaultLogSet)
- m_defaultLog.info(message);
- }
-
- /**
- * Log a message with the INFO Level, with arguments and with a throwable arguments
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- * @param throwable Throwable associated with the logging request
- */
- public void info(String key, Object[] params, Throwable throwable)
- {
- if (!isInfoEnabled()) return;
- String message = evalResourceBundle(key, params);
- m_logInterface.info(message, throwable);
- if (defaultLogSet)
- m_defaultLog.info(message, throwable);
- }
-
- /**
- * Log a message with the WARN Level
- * @param key resource bundle key for the message to log
- *
- * @deprecated use warn (String key, null) instead
- */
- public void warn(String key)
- {
- if (!isWarnEnabled()) return;
- String message = evalResourceBundle(key);
- m_logInterface.warn(message);
- if (defaultLogSet)
- m_defaultLog.warn(message);
- }
-
- /**
- * Log a throwable message with te WARN Level
- * @param throwable Throwable associated with the logging request
- */
- public void warn(Throwable throwable)
- {
- if (!isWarnEnabled()) return;
- String message = throwable.getLocalizedMessage();
- m_logInterface.warn(message, throwable);
- if (defaultLogSet)
- m_defaultLog.warn(message, throwable);
- }
-
- /**
- * Log a message with the WARN Level and with a throwable arguments
- * @param key resource bundle key for the message to log
- * @param throwable Throwable associated with the logging request
- */
- public void warn(String key, Throwable throwable)
- {
- if (!isWarnEnabled()) return;
- String message = evalResourceBundle(key);
- m_logInterface.warn(message, throwable);
- if (defaultLogSet)
- m_defaultLog.warn(message, throwable);
- }
-
- /**
- * Log a message with the WARN Level and with arguments
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- */
- public void warn(String key, Object[] params)
- {
- if (!isWarnEnabled()) return;
- String message = evalResourceBundle(key, params);
- m_logInterface.warn(message);
- if (defaultLogSet)
- m_defaultLog.warn(message);
- }
-
- /**
- * Log a message with the WARN Level, with arguments and with a throwable arguments
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- * @param throwable Throwable associated with the logging request
- */
- public void warn(String key, Object[] params, Throwable throwable)
- {
- if (!isWarnEnabled()) return;
- String message = evalResourceBundle(key, params);
- m_logInterface.warn(message, throwable);
- if (defaultLogSet)
- m_defaultLog.warn(message, throwable);
- }
-
- /**
- * Log a message with the ERROR Level
- * @param key resource bundle key for the message to log
- *
- * @deprecated use error (String key, null) instead
- */
- public void error(String key)
- {
- if (!isErrorEnabled()) return;
- String message = evalResourceBundle(key);
- m_logInterface.error(message);
- if (defaultLogSet)
- m_defaultLog.error(message);
- }
-
- /**
- * Log a throwable message with te ERROR Level
- * @param throwable Throwable associated with the logging request
- */
- public void error(Throwable throwable)
- {
- if (!isErrorEnabled()) return;
- String message = throwable.getLocalizedMessage();
- m_logInterface.error(message, throwable);
- if (defaultLogSet)
- m_defaultLog.error(message, throwable);
- }
-
- /**
- * Log a message with the ERROR Level and with a throwable arguments
- * @param key resource bundle key for the message to log
- * @param throwable Throwable associated with the logging request
- */
- public void error(String key, Throwable throwable)
- {
- if (!isErrorEnabled()) return;
- String message = evalResourceBundle(key);
- m_logInterface.error(message, throwable);
- if (defaultLogSet)
- m_defaultLog.error(message, throwable);
- }
-
- /**
- * Log a message with the ERROR Level and with arguments
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- */
- public void error(String key, Object[] params)
- {
- if (!isErrorEnabled()) return;
- String message = evalResourceBundle(key, params);
- m_logInterface.error(message);
- if (defaultLogSet)
- m_defaultLog.error(message);
- }
-
- /**
- * Log a message with the ERROR Level, with arguments and with a throwable arguments
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- * @param throwable Throwable associated with the logging request
- */
- public void error(String key, Object[] params, Throwable throwable)
- {
- if (!isErrorEnabled()) return;
- String message = evalResourceBundle(key, params);
- m_logInterface.error(message, throwable);
- if (defaultLogSet)
- m_defaultLog.error(message, throwable);
- }
-
- /**
- * Log a message with the FATAL Level
- * @param key resource bundle key for the message to log
- *
- * @deprecated use fatal (String key, null) instead
- */
- public void fatal(String key)
- {
- if (!isFatalEnabled()) return;
- String message = evalResourceBundle(key);
- m_logInterface.fatal(message);
- if (defaultLogSet)
- m_defaultLog.fatal(message);
- }
-
- /**
- * Log a throwable message with te FATAL Level
- * @param throwable Throwable associated with the logging request
- */
- public void fatal(Throwable throwable)
- {
- if (!isFatalEnabled()) return;
- String message = throwable.getLocalizedMessage();
- m_logInterface.fatal(message, throwable);
- if (defaultLogSet)
- m_defaultLog.fatal(message, throwable);
- }
-
- /**
- * Log a message with the FATAL Level and with a throwable arguments
- * @param key resource bundle key for the message to log
- * @param throwable Throwable associated with the logging request
- */
- public void fatal(String key, Throwable throwable)
- {
- if (!isFatalEnabled()) return;
- String message = evalResourceBundle(key);
- m_logInterface.fatal(message, throwable);
- if (defaultLogSet)
- m_defaultLog.fatal(message, throwable);
- }
-
- /**
- * Log a message with the FATAL Level and with arguments
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- */
- public void fatal(String key, Object[] params)
- {
- if (!isFatalEnabled()) return;
- String message = evalResourceBundle(key, params);
- m_logInterface.fatal(message);
- if (defaultLogSet)
- m_defaultLog.fatal(message);
- }
-
- /**
- * Log a message with the FATAL Level, with arguments and with a throwable arguments
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- * @param throwable Throwable associated with the logging request
- */
- public void fatal(String key, Object[] params, Throwable throwable)
- {
- if (!isFatalEnabled()) return;
- String message = evalResourceBundle(key, params);
- m_logInterface.fatal(message, throwable);
- if (defaultLogSet)
- m_defaultLog.fatal(message, throwable);
- }
-
-
- /**
- * Log a message with the DEBUG Level
- * @param baseName The name of resource bundle to localize message
- * @param key The resource bundle key to retrieve a localised string
- */
- public void debugb(String baseName, String key)
- {
- if (!isDebugEnabled()) return;
- String message = evalResourceBundle(baseName, key);
- m_logInterface.debug(message);
- if (defaultLogSet)
- m_defaultLog.debug(message);
- }
-
- /**
- * Log a message with the DEBUG Level and with a throwable arguments
- * @param baseName The name of resource bundle to localize message
- * @param key The resource bundle key to retrieve a localised string
- * @param throwable Throwable associated with the log message
- */
- public void debugb(String baseName, String key, Throwable throwable)
- {
- if (!isDebugEnabled()) return;
- String message = evalResourceBundle(baseName, key);
- m_logInterface.debug(message, throwable);
- if (defaultLogSet)
- m_defaultLog.debug(message, throwable);
- }
-
- /**
- * Log a message with the DEBUG Level and with arguments
- * @param baseName The name of resource bundle to localize message
- * @param key The resource bundle key to retrieve a localised string
- * @param params parameters passed to the message
- */
- public void debugb(String baseName, String key, Object[] params)
- {
- if (!isDebugEnabled()) return;
- String message = evalResourceBundle(baseName, key, params);
- m_logInterface.debug(message);
- if (defaultLogSet)
- m_defaultLog.debug(message);
- }
-
- /**
- * Log a message with the DEBUG Level, with arguments and with a throwable arguments
- * @param baseName The name of resource bundle to localize message
- * @param key The resource bundle key to retrieve a localised string
- * @param params parameters passed to the message
- * @param throwable Throwable associated with the log message
- */
- public void debugb(String baseName, String key, Object[] params, Throwable throwable)
- {
- if (!isDebugEnabled()) return;
- String message = evalResourceBundle(baseName, key, params);
- m_logInterface.debug(message, throwable);
- if (defaultLogSet)
- m_defaultLog.debug(message, throwable);
- }
-
-
- /**
- * Log a message with the INFO Level
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- */
- public void infob(String baseName, String key)
- {
- if (!isInfoEnabled()) return;
- String message = evalResourceBundle(baseName, key);
- m_logInterface.info(message);
- if (defaultLogSet)
- m_defaultLog.info(message);
- }
-
- /**
- * Log a message with the INFO Level and with a throwable arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param throwable Throwable associated with the log message
- */
- public void infob(String baseName, String key, Throwable throwable)
- {
- if (!isInfoEnabled()) return;
- String message = evalResourceBundle(baseName, key);
- m_logInterface.info(message, throwable);
- if (defaultLogSet)
- m_defaultLog.info(message, throwable);
- }
-
- /**
- * Log a message with the INFO Level and with arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- */
- public void infob(String baseName, String key, Object[] params)
- {
- if (!isInfoEnabled()) return;
- String message = evalResourceBundle(baseName, key, params);
- m_logInterface.info(message);
- if (defaultLogSet)
- m_defaultLog.info(message);
- }
-
- /**
- * Log a message with the INFO Level, with arguments and with a throwable arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- * @param throwable Throwable associated with the log message
- */
- public void infob(String baseName, String key, Object[] params, Throwable throwable)
- {
- if (!isInfoEnabled()) return;
- String message = evalResourceBundle(baseName, key, params);
- m_logInterface.info(message, throwable);
- if (defaultLogSet)
- m_defaultLog.info(message, throwable);
- }
-
- /**
- * Log a message with the WARN Level
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- */
- public void warnb(String baseName, String key)
- {
- if (!isWarnEnabled()) return;
- String message = evalResourceBundle(baseName, key);
- m_logInterface.warn(message);
- if (defaultLogSet)
- m_defaultLog.warn(message);
- }
-
- /**
- * Log a message with the WARN Level and with a throwable arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param throwable Throwable associated with the log message
- */
- public void warnb(String baseName, String key, Throwable throwable)
- {
- if (!isWarnEnabled()) return;
- String message = evalResourceBundle(baseName, key);
- m_logInterface.warn(message, throwable);
- if (defaultLogSet)
- m_defaultLog.warn(message, throwable);
- }
-
- /**
- * Log a message with the WARN Level and with arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- */
- public void warnb(String baseName, String key, Object[] params)
- {
- if (!isWarnEnabled()) return;
- String message = evalResourceBundle(baseName, key, params);
- m_logInterface.warn(message);
- if (defaultLogSet)
- m_defaultLog.warn(message);
- }
-
- /**
- * Log a message with the WARN Level, with arguments and with a throwable arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- * @param throwable Throwable associated with the log message
- */
- public void warnb(String baseName, String key, Object[] params, Throwable throwable)
- {
- if (!isWarnEnabled()) return;
- String message = evalResourceBundle(baseName, key, params);
- m_logInterface.warn(message, throwable);
- if (defaultLogSet)
- m_defaultLog.warn(message, throwable);
- }
-
- /**
- * Log a message with the ERROR Level
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- */
- public void errorb(String baseName, String key)
- {
- if (!isErrorEnabled()) return;
- String message = evalResourceBundle(baseName, key);
- m_logInterface.error(message);
- if (defaultLogSet)
- m_defaultLog.error(message);
- }
-
- /**
- * Log a message with the ERROR Level and with a throwable arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param throwable Throwable associated with the log message
- */
- public void errorb(String baseName, String key, Throwable throwable)
- {
- if (!isErrorEnabled()) return;
- String message = evalResourceBundle(baseName, key);
- m_logInterface.error(message, throwable);
- if (defaultLogSet)
- m_defaultLog.error(message, throwable);
- }
-
- /**
- * Log a message with the ERROR Level and with arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- */
- public void errorb(String baseName, String key, Object[] params)
- {
- if (!isErrorEnabled()) return;
- String message = evalResourceBundle(baseName, key, params);
- m_logInterface.error(message);
- if (defaultLogSet)
- m_defaultLog.error(message);
- }
-
- /**
- * Log a message with the ERROR Level, with arguments and with a throwable arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- * @param throwable Throwable associated with the log message
- */
- public void errorb(String baseName, String key, Object[] params, Throwable throwable)
- {
- if (!isErrorEnabled()) return;
- String message = evalResourceBundle(baseName, key, params);
- m_logInterface.error(message, throwable);
- if (defaultLogSet)
- m_defaultLog.error(message, throwable);
- }
-
- /**
- * Log a message with the FATAL Level
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- */
- public void fatalb(String baseName, String key)
- {
- if (!isFatalEnabled()) return;
- String message = evalResourceBundle(baseName, key);
- m_logInterface.fatal(message);
- if (defaultLogSet)
- m_defaultLog.fatal(message);
- }
-
- /**
- * Log a message with the FATAL Level and with a throwable arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param throwable Throwable associated with the log message
- */
- public void fatalb(String baseName, String key, Throwable throwable)
- {
- if (!isFatalEnabled()) return;
- String message = evalResourceBundle(baseName, key);
- m_logInterface.fatal(message, throwable);
- if (defaultLogSet)
- m_defaultLog.fatal(message, throwable);
- }
-
- /**
- * Log a message with the FATAL Level and with arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- */
- public void fatalb(String baseName, String key, Object[] params)
- {
- if (!isFatalEnabled()) return;
- String message = evalResourceBundle(baseName, key, params);
- m_logInterface.fatal(message);
- if (defaultLogSet)
- m_defaultLog.fatal(message);
- }
-
- /**
- * Log a message with the FATAL Level, with arguments and with a throwable arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- * @param throwable Throwable associated with the log message
- */
- public void fatalb(String baseName, String key, Object[] params, Throwable throwable)
- {
- if (!isFatalEnabled()) return;
- String message = evalResourceBundle(baseName, key, params);
- m_logInterface.fatal(message, throwable);
- if (defaultLogSet)
- m_defaultLog.fatal(message, throwable);
- }
-
-
-
- // -------------------------------------------------------------------------------------
- // private methods
- // -------------------------------------------------------------------------------------
-
- private String evalResourceBundle(String key)
- {
- //if (key == null) key="null";
- //return (new ResourceMessage(m_resourceBundle, key)).toString();
- return getString(key);
- }
-
- private String evalResourceBundle(String key, Object[] params)
- {
- //if (key == null) key="null";
- //return (new ResourceMessage(m_resourceBundle, key, params)).toString();
- return getString(key, params);
- }
-
- private String evalResourceBundle(String resBundle, String key)
- {
- //if (key == null) key="null";
- //return (new ResourceMessage(resBundle, key)).toString();
- return getString(resBundle, key);
- }
-
- private String evalResourceBundle(String resBundle, String key, Object[] params)
- {
- //if (key == null) key="null";
- //return (new ResourceMessage(resBundle, key, params)).toString();
- return getString(resBundle, key, params);
- }
-
-}
Modified: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LogInterface.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LogInterface.java 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LogInterface.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -31,27 +31,80 @@
/**
* This interface must be implemented by any underlying log subsystem to which CLF acts as a veneer.
*
- * The following log subsystems are supported:
- * <ul>
- * <li>Jakarta Commons Logging (JCL). JCL can delegate to various other logging subsystems, such as:
- * <ul>
- * <li>log4j</li>
- * <li>JDK 1.4 logging</li>
- * <li>Windows NT syslog</li>
- * <li>console</li>
- * </ul>
- * </li>
- * <li>.net logging. (must be JDK 1.1 compliant for compilation by the Microsoft compiler)</li>
- * </ul>
+ * Implementations are provided for Jakarta Commons Logging (JCL), which in turn supports log4j, jdk14 and others.
+ * We also provide a basic built in one to minimise 3rd party dependencies. See LoggingEnvironmentBean for config.
*
* @author Thomas Rischbeck <thomas.rischbeck at arjuna.com>
* @version $Revision: 2342 $ $Date: 2006-03-30 14:06:17 +0100 (Thu, 30 Mar 2006) $
* @since clf-2.0
*/
-public interface LogInterface extends AbstractLogInterface
+public interface LogInterface
{
+ /**
+ * Is DEBUG logging currently enabled?
+ *
+ * Call this method to prevent having to perform expensive operations
+ * (for example, <code>String</code> concatination)
+ * when the log level is more than DEBUG.
+ *
+ * @return True if the logger is enabled for DEBUG, false otherwise
+ */
+ boolean isDebugEnabled();
/**
+ * Is INFO logging currently enabled?
+ *
+ * Call this method to prevent having to perform expensive operations
+ * (for example, <code>String</code> concatination)
+ * when the log level is more than INFO.
+ *
+ * @return True if the logger is enabled for INFO, false otherwise
+ */
+ boolean isInfoEnabled();
+
+ /**
+ * Is WARN logging currently enabled?
+ *
+ * Call this method to prevent having to perform expensive operations
+ * (for example, <code>String</code> concatination)
+ * when the log level is more than WARN.
+ *
+ * @return True if the logger is enabled for WARN, false otherwise
+ */
+ boolean isWarnEnabled();
+
+ /**
+ * Is ERROR logging currently enabled?
+ *
+ * Call this method to prevent having to perform expensive operations
+ * (for example, <code>String</code> concatination)
+ * when the log level is more than ERROR.
+ *
+ * @return True if the logger is enabled for ERROR, false otherwise
+ */
+ boolean isErrorEnabled();
+
+ /**
+ * Is FATAL logging currently enabled?
+ *
+ * Call this method to prevent having to perform expensive operations
+ * (for example, <code>String</code> concatination)
+ * when the log level is more than FATAL.
+ *
+ * @return True if the logger is enabled for FATAL, false otherwise
+ */
+ boolean isFatalEnabled();
+
+ /**
+ * Is TRACE logging currently enabled?
+ *
+ * Call this method to prevent having to perform expensive operations
+ * (for example, <code>String</code> concatination)
+ * when the log level is more than TRACE.
+ */
+ public boolean isTraceEnabled();
+
+ /**
* <p> Log a message with trace log level. </p>
*
* @param message log this message
Modified: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LogNoi18nImpl.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LogNoi18nImpl.java 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LogNoi18nImpl.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -42,60 +42,50 @@
*/
public class LogNoi18nImpl implements LogNoi18n
{
-
-
/**
* Log interface (no i18n provided).
*/
- private LogInterface m_logInterface = null;
+ private final LogInterface m_logInterface;
/**
- * default resource bundle for this logger.
- *
- * Note that it is also possible to use a resource bundle name as argument in log statements if so required.
- * (this is only used by the AMS client library and we might remove this feature because of performance)
- *
- * all extra resource bundles are kept in {@link #m_extraResBundles m_extraResBundles}.
- */
- protected String m_resourceBundle = "no resource bundle set";
-
- /**
- * extra resource bundles (if more than one is in use)
- *
- * Note that there is a performance issue when more than one resource bundles is in use.
- */
- protected String[] m_extraResBundles = null;
-
- /**
* Level for finer-debug logging.
*
* @see com.arjuna.common.util.logging.DebugLevel for possible values.
*/
- private long m_debugLevel = DebugLevel.NO_DEBUGGING;
+ private final long m_debugLevel;
/**
* log level for visibility-based logging
*
* @see com.arjuna.common.util.logging.VisibilityLevel for possible values.
*/
- private long m_visLevel = VisibilityLevel.VIS_ALL;
+ private final long m_visLevel;
/**
* log level for facility code
*
* @see com.arjuna.common.util.logging.FacilityCode for possible values.
*/
- private long m_facLevel = FacilityCode.FAC_ALL;
+ private final long m_facLevel;
/**
* constructor
*
- * @param logInterface
+ * @param logInterface the underlying logger to wrap
+ * @param dl The finer debugging value.
+ * See {@link com.arjuna.common.util.logging.DebugLevel DebugLevel} for possible values.
+ * @param vl The visibility level value.
+ * See {@link com.arjuna.common.util.logging.VisibilityLevel VisibilityLevel} for possible values.
+ * @param fl The facility code level value.
+ * See {@link com.arjuna.common.util.logging.FacilityCode FacilityCode} for possible values.
*/
- public LogNoi18nImpl(LogInterface logInterface)
+ public LogNoi18nImpl(LogInterface logInterface, long dl, long vl, long fl)
{
m_logInterface = logInterface;
+ m_debugLevel = dl;
+ m_visLevel = vl;
+ m_facLevel = fl;
}
@@ -145,128 +135,9 @@
}
-
-
/**************************** Debug Granularity Extension ***************************/
/**
- * Set the debug level, the visibility level, and the facility code.
- *
- * @param dl The finer debugging value.
- * See {@link com.arjuna.common.util.logging.DebugLevel DebugLevel} for possible values.
- * @param vl The visibility level value.
- * See {@link com.arjuna.common.util.logging.VisibilityLevel VisibilityLevel} for possible values.
- * @param fl The facility code level value.
- * See {@link com.arjuna.common.util.logging.FacilityCode FacilityCode} for possible values.
- */
- public void setLevels(long dl, long vl, long fl)
- {
- m_debugLevel = dl;
- m_visLevel = vl;
- m_facLevel = fl;
- }
-
- /**
- * Return the finer debug level.
- *
- * @return The finer debugging level value associated with the logger
- * @see com.arjuna.common.util.logging.DebugLevel for possible return values.
- */
- public long getDebugLevel()
- {
- return m_debugLevel;
- }
-
- /**
- * Set the debug level as available in the {@link com.arjuna.common.util.logging.DebugLevel DebugLevel}.
- *
- * @param level The finer debugging value
- * @see com.arjuna.common.util.logging.DebugLevel for possible values of <code>level</code>.
- */
- public void setDebugLevel(long level)
- {
- m_debugLevel = level;
- }
-
- /**
- * Merge the debug level provided with that currently used by
- * the controller.
- *
- * @param level The finer debugging value
- * @see com.arjuna.common.util.logging.DebugLevel for possible values of <code>level</code>.
- */
- public void mergeDebugLevel(long level)
- {
- m_debugLevel |= level;
- }
-
- /**
- * Return the visibility level.
- *
- * @return The visibility level value associated with the Logger
- * @see com.arjuna.common.util.logging.VisibilityLevel for possible return values.
- */
- public long getVisibilityLevel()
- {
- return m_visLevel;
- }
-
- /**
- * Set the visibility level.
- *
- * @param level The visibility level value
- * @see com.arjuna.common.util.logging.VisibilityLevel for possible values of <code>level</code>.
- */
- public void setVisibilityLevel(long level)
- {
- m_visLevel = level;
- }
-
- /**
- * Merge the visibility level provided with that currently used by the Logger.
- *
- * @param level The visibility level value
- * @see com.arjuna.common.util.logging.VisibilityLevel for possible values of <code>level</code>.
- */
- public void mergeVisibilityLevel(long level)
- {
- m_visLevel |= level;
- }
-
- /**
- * Return the facility code.
- *
- * @return The facility code value associated with the Logger.
- * @see com.arjuna.common.util.logging.FacilityCode for possible return values.
- */
- public long getFacilityCode()
- {
- return m_facLevel;
- }
-
- /**
- * Set the facility code.
- *
- * @param level The facility code value
- * @see com.arjuna.common.util.logging.FacilityCode for possible values of <code>level</code>.
- */
- public void setFacilityCode(long level)
- {
- m_facLevel = level;
- }
-
- /**
- * Merge the debug level provided with that currently used by the Logger.
- *
- * @param level The visibility level value
- * @see com.arjuna.common.util.logging.FacilityCode for possible values of <code>level</code>.
- */
- public void mergeFacilityCode(long level)
- {
- m_facLevel |= level;
- }
-
- /**
* Is it allowed to print finer debugging statements?
*
* This method returns true when the following is set:
@@ -285,45 +156,6 @@
}
/**
- * Is it allowed to print finer debugging statements with a given debug level?
- *
- * This method assumes that:
- * <ul>
- * <li>visibility level = <code>VisibilityLevel.VIS_ALL</code>.</li>
- * <li>facility code = <code>FacilityCode.FAC_ALL</code>.</li>
- * </ul>
- *
- * @return true if the Logger allows logging for the finer debugging value <code>dLevel</code>.
- * i.e., dLevel is either equals or greater than the finer debug level assigned to the Logger.
- * @param dLevel The debug finer level to check for.
- */
- public boolean debugAllowed(long dLevel)
- {
- return debugAllowed(dLevel, VisibilityLevel.VIS_ALL, FacilityCode.FAC_ALL);
- }
-
- /**
- * Is it allowed to print finer debugging statements with a given debug level
- * and visibility level?
- *
- * This method assumes that:
- * <ul>
- * <li>facility code = <code>FacilityCode.FAC_ALL</code>.</li>
- * </ul>
- *
- * @return true if the Logger allows logging for the finer debugging value <code>dLevel</code>
- * and visibility level <code>vLevel</code>.
- * i.e., dLevel is equal or greater than the finer debug level assigned to the Logger
- * and vLevel is equal or greater than the visiblity level.
- * @param dLevel The debug finer level to check for.
- * @param vLevel The debug visibilty level to check for.
- */
- public boolean debugAllowed(long dLevel, long vLevel)
- {
- return debugAllowed(dLevel, vLevel, FacilityCode.FAC_ALL);
- }
-
- /**
* Is it allowed to print finer debugging statements with a given debug level,
* visibility level and facility code level?
*
@@ -336,7 +168,7 @@
* @param vLevel The debug visibilty level to check for.
* @param fLevel The facility code level to check for.
*/
- public boolean debugAllowed(long dLevel, long vLevel, long fLevel)
+ private boolean debugAllowed(long dLevel, long vLevel, long fLevel)
{
// check the underlying logger threshold as well as (but after, due to cost)
// our own filters, as many use points call debugAllowed rather than isDebugEnabled.
@@ -348,32 +180,8 @@
* Finer-Granularity Debug Methods.
**********************************************************************************************************/
- /**
- * Log a message with the DEBUG Level and with finer granularity. The debug message
- * is sent to the output only if the specified debug level, visibility level, and facility code
- * match those allowed by the logger.
- * <p>
- * <b>Note:</b> this method does not use i18n. ie, message is directly used for log output.
- *
- * @param dl The debug finer level associated with the log message. That is, the logger object allows
- * to log only if the DEBUG level is allowed and dl is either equals or greater the debug level assigned to
- * the logger Object
- * @param vl The visibility level associated with the log message. That is, the logger object allows
- * to log only if the DEBUG level is allowed and vl is either equals or greater the visibility level assigned to
- * the logger Object
- * @param fl The facility code level associated with the log message. That is, the logger object allows
- * to log only if the DEBUG level is allowed and fl is either equals or greater the facility code level assigned to
- * the logger Object
- * @param message The message to log.
- */
- public void debug(long dl, long vl, long fl, Object message)
- {
- if (debugAllowed(dl, vl, fl))
- {
- debug(message);
- }
- }
+
/**
* Log a message with the DEBUG Level and with finer granularity. The debug message
* is sent to the output only if the specified debug level, visibility level, and facility code
@@ -405,16 +213,6 @@
*
* @param message the message to log
*/
- public void debug(Object message)
- {
- m_logInterface.debug(message);
- }
-
- /**
- * Log a message with DEBUG Level
- *
- * @param message the message to log
- */
public void debug(String message)
{
m_logInterface.debug(message);
@@ -425,16 +223,6 @@
*
* @param message the message to log
*/
- public void info(Object message)
- {
- m_logInterface.info(message);
- }
-
- /**
- * Log a message with INFO Level
- *
- * @param message the message to log
- */
public void info(String message)
{
m_logInterface.info(message);
@@ -445,16 +233,6 @@
*
* @param message the message to log
*/
- public void warn(Object message)
- {
- m_logInterface.warn(message);
- }
-
- /**
- * Log a message with WARN Level
- *
- * @param message the message to log
- */
public void warn(String message)
{
m_logInterface.warn(message);
@@ -465,7 +243,7 @@
*
* @param message the message to log
*/
- public void error(Object message)
+ public void error(Throwable message)
{
m_logInterface.error(message);
}
@@ -480,22 +258,11 @@
m_logInterface.error(message);
}
-
/**
* Log a message with FATAL Level
*
* @param message the message to log
*/
- public void fatal(Object message)
- {
- m_logInterface.fatal(message);
- }
-
- /**
- * Log a message with FATAL Level
- *
- * @param message the message to log
- */
public void fatal(String message)
{
m_logInterface.fatal(message);
Modified: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LoggingEnvironmentBean.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LoggingEnvironmentBean.java 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LoggingEnvironmentBean.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -36,12 +36,8 @@
private volatile String language = "en";
private volatile String country = "US";
- @FullPropertyName(name = "com.arjuna.common.util.logging.default")
- private volatile boolean useDefaultLog = false;
+ private volatile String loggingFactory = "com.arjuna.common.internal.util.logging.jakarta.JakartaLogFactory;com.arjuna.common.internal.util.logging.jakarta.Log4JLogger";
- @FullPropertyName(name = "com.arjuna.common.util.logger")
- private volatile String loggingSystem = "log4j";
-
@FullPropertyName(name = "com.arjuna.common.util.logging.DebugLevel")
private volatile String debugLevel = "0x00000000";
@@ -99,49 +95,40 @@
}
/**
- * Should the internal default log system be used in addition to the underlying logger.
+ * Returns the factory information for the underlying logging system.
+ * The string should consist of a classname for a class which implements LogFactoryInterface,
+ * plus an optional semicolon separated suffix containing a parameter string to pass to the factory impl.
*
- * Default: false
- * Equivalent deprecated property: com.arjuna.common.util.logging.default
+ * Options corresponding to the old log configuration mechanism are as follows:
*
- * @return true if the default log should be enabled, otherwise false.
- */
- public boolean isUseDefaultLog()
- {
- return useDefaultLog;
- }
-
- /**
- * Enables the default log system.
+ * log4j: com.arjuna.common.internal.util.logging.jakarta.JakartaLogFactory;com.arjuna.common.internal.util.logging.jakarta.Log4JLogger
+ * jdk14: com.arjuna.common.internal.util.logging.jakarta.JakartaLogFactory;org.apache.commons.logging.impl.Jdk14Logger
+ * simple: com.arjuna.common.internal.util.logging.jakarta.JakartaLogFactory;org.apache.commons.logging.impl.SimpleLog
+ * noop: com.arjuna.common.internal.util.logging.jakarta.JakartaLogFactory;org.apache.commons.logging.impl.NoOpLog
+ * log4j_releveler: com.arjuna.common.internal.util.logging.jakarta.JakartaRelevelingLogFactory;com.arjuna.common.internal.util.logging.jakarta.Log4JLogger
+ * jakarta: com.arjuna.common.internal.util.logging.jakarta.JakartaLogFactory
*
- * @param useDefaultLog true if default log should be enabled, false otherwise.
- */
- public void setUseDefaultLog(boolean useDefaultLog)
- {
- this.useDefaultLog = useDefaultLog;
- }
-
- /**
- * Returns the identifier for the underlying logging system.
+ * Note that the above are run through commons logging, so that jar is required on the classpath in most cases.
*
- * Default: "log4j"
- * Equivalent deprecated property: com.arjuna.common.util.logger
+ * built-in (no 3rd party deps): "com.arjuna.common.internal.util.logging.basic.BasicLogFactory"
*
- * @return the identifier of the underlying logging system.
+ * Default: log4j via. commons logging (the first option in the list above)
+ *
+ * @return the factory information for the underlying logging system.
*/
- public String getLoggingSystem()
+ public String getLoggingFactory()
{
- return loggingSystem;
+ return loggingFactory;
}
/**
- * Sets the identifier for the underlying logging system.
+ * Sets the factory information for the underlying logging system.
*
- * @param loggingSystem the identifier for the underlying logging system.
+ * @param loggingFactory the factory information for the underlying logging system.
*/
- public void setLoggingSystem(String loggingSystem)
+ public void setLoggingFactory(String loggingFactory)
{
- this.loggingSystem = loggingSystem;
+ this.loggingFactory = loggingFactory;
}
/**
Modified: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LoggingEnvironmentBeanMBean.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LoggingEnvironmentBeanMBean.java 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LoggingEnvironmentBeanMBean.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -35,14 +35,10 @@
void setCountry(String country);
- boolean isUseDefaultLog();
+ String getLoggingFactory();
- void setUseDefaultLog(boolean useDefaultLog);
+ void setLoggingFactory(String loggingFactory);
- String getLoggingSystem();
-
- void setLoggingSystem(String loggingSystem);
-
String getDebugLevel();
void setDebugLevel(String debugLevel);
Copied: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/Logi18nImpl.java (from rev 29850, labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LogImpl.java)
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/Logi18nImpl.java (rev 0)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/Logi18nImpl.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -0,0 +1,727 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+* Logi18nImpl.java
+*
+* Copyright (c) 2003 Arjuna Technologies Ltd.
+* Arjuna Technologies Ltd. Confidential
+*
+* Created on Jun 30, 2003, 12:48:49 PM by Thomas Rischbeck
+*/
+package com.arjuna.common.internal.util.logging;
+
+import com.arjuna.common.util.logging.*;
+
+import java.util.ResourceBundle;
+import java.util.PropertyResourceBundle;
+import java.util.Locale;
+import java.util.MissingResourceException;
+
+/**
+ * Implementation of the Log interface without i18n support.
+ *
+ * Most log subsystems do not provide i18n, therefore we do resource
+ * bundle evaluation in this class.
+ *
+ * @author Thomas Rischbeck <thomas.rischbeck at arjuna.com>
+ * @version $Revision: 2342 $ $Date: 2006-03-30 14:06:17 +0100 (Thu, 30 Mar 2006) $
+ * @since clf-2.0
+ */
+public class Logi18nImpl implements Logi18n
+{
+ private ResourceBundle m_defaultResourceBundle = null;
+
+ /**
+ * extra resource bundles (if more than one is in use)
+ *
+ * Note that there is a performance issue when more than one resource bundles is in use.
+ *
+ * @see #m_defaultResourceBundle
+ */
+ private ResourceBundle[] m_extraResourceBundles = null;
+
+ /**
+ * Level for finer-debug logging.
+ *
+ * @see DebugLevel for possible values.
+ */
+ private long m_debugLevel = DebugLevel.NO_DEBUGGING;
+
+ /**
+ * log level for visibility-based logging
+ *
+ * @see VisibilityLevel for possible values.
+ */
+ private long m_visLevel = VisibilityLevel.VIS_ALL;
+
+ /**
+ * log level for facility code
+ *
+ * @see FacilityCode for possible values.
+ */
+ private long m_facLevel = FacilityCode.FAC_ALL;
+
+ /**
+ * Interface to the log subsystem to use
+ */
+ private final LogInterface m_logInterface;
+
+ /**
+ * constructor
+ *
+ * @param logInterface the underlying logger to wrap
+ * @param resBundle bundle used for this logger (if a resource bundle is used per logger)
+ *
+ * @param dl The finer debugging value.
+ * See {@link DebugLevel DebugLevel} for possible values.
+ * @param vl The visibility level value.
+ * See {@link VisibilityLevel VisibilityLevel} for possible values.
+ * @param fl The facility code level value.
+ * See {@link FacilityCode FacilityCode} for possible values.
+ */
+ public Logi18nImpl(LogInterface logInterface, String resBundle, long dl, long vl, long fl)
+ {
+ m_logInterface = logInterface;
+ setLevels(dl, vl, fl);
+ addResourceBundle(resBundle);
+ }
+
+ /**
+ * Add the given resource bundle to this logger.
+ *
+ * @param bundleName The name of the resource bundle.
+ */
+ public synchronized void addResourceBundle(String bundleName)
+ {
+ try
+ {
+ // if no default resource bundle has been set, use this one as the default one
+ if (m_defaultResourceBundle == null)
+ {
+ m_defaultResourceBundle = PropertyResourceBundle.getBundle(bundleName, Locale.getDefault(), Thread.currentThread().getContextClassLoader());
+ }
+
+ // otherwise, add it to the extra resource bundles supported by this logger
+ else if (m_extraResourceBundles == null)
+ {
+ m_extraResourceBundles = new ResourceBundle[]{PropertyResourceBundle.getBundle(bundleName, Locale.getDefault(), Thread.currentThread().getContextClassLoader())};
+ }
+ else
+ {
+ ResourceBundle[] oldExtraResBundles = m_extraResourceBundles;
+ m_extraResourceBundles = new ResourceBundle[oldExtraResBundles.length + 1];
+ System.arraycopy(oldExtraResBundles, 0, m_extraResourceBundles, 0, oldExtraResBundles.length);
+ m_extraResourceBundles[oldExtraResBundles.length] = PropertyResourceBundle.getBundle(bundleName, Locale.getDefault(), Thread.currentThread().getContextClassLoader());
+ }
+ }
+ catch (MissingResourceException mre)
+ {
+ System.err.println("resource bundle " + mre.getClassName() + " not found!");
+ }
+ }
+
+
+ /**
+ * Determine if this logger is enabled for DEBUG messages.
+ * @return True if the logger is enabled for DEBUG, false otherwise
+ */
+ public boolean isDebugEnabled()
+ {
+ return m_logInterface.isDebugEnabled();
+ }
+
+ /**
+ * Determine if this logger is enabled for INFO messages.
+ * @return True if the logger is enabled for INFO, false otherwise
+ */
+ public boolean isInfoEnabled()
+ {
+ return m_logInterface.isInfoEnabled();
+ }
+
+ /**
+ * Determine if this logger is enabled for WARN messages.
+ * @return True if the logger is enabled for WARN, false otherwise
+ */
+ public boolean isWarnEnabled()
+ {
+ return m_logInterface.isWarnEnabled();
+ }
+
+ /**
+ * Determine if this logger is enabled for ERROR messages.
+ * @return True if the logger is enabled for ERROR, false otherwise
+ */
+ public boolean isErrorEnabled()
+ {
+ return m_logInterface.isErrorEnabled();
+ }
+
+ /**
+ * Determine if this logger is enabled for FATAL messages.
+ * @return True if the logger is enabled for FATAL, false otherwise
+ */
+ public boolean isFatalEnabled()
+ {
+ return m_logInterface.isFatalEnabled();
+ }
+
+
+
+
+ /**************************** Debug Granularity Extension ***************************/
+
+ /**
+ * Set the debug level, the visibility level, and the facility code.
+ *
+ * @param dl The finer debugging value.
+ * See {@link DebugLevel DebugLevel} for possible values.
+ * @param vl The visibility level value.
+ * See {@link VisibilityLevel VisibilityLevel} for possible values.
+ * @param fl The facility code level value.
+ * See {@link FacilityCode FacilityCode} for possible values.
+ */
+ private void setLevels(long dl, long vl, long fl)
+ {
+ m_debugLevel = dl;
+ m_visLevel = vl;
+ m_facLevel = fl;
+ }
+
+ /**
+ * Is it allowed to print finer debugging statements?
+ *
+ * This method returns true when the following is set:
+ * <ul>
+ * <li>finer debug level = <code>DebugLevel.FULL_DEBUGGING</code>.</li>
+ * <li>visibility level = <code>VisibilityLevel.VIS_ALL</code>.</li>
+ * <li>facility code = <code>FacilityCode.FAC_ALL</code>.</li>
+ * </ul>
+ *
+ * @return true if the Logger allows full logging
+ */
+ public boolean debugAllowed()
+ {
+ return debugAllowed(DebugLevel.FULL_DEBUGGING, VisibilityLevel.VIS_ALL,
+ FacilityCode.FAC_ALL);
+ }
+
+ /**
+ * Is it allowed to print finer debugging statements with a given debug level,
+ * visibility level and facility code level?
+ *
+ * @return true if the Logger allows logging for the finer debugging value <code>dLevel</code>,
+ * visibility level <code>vLevel</code> and facility code level <code>fLevel</code>.
+ * i.e., dLevel is equal or greater than the finer debug level assigned to the Logger
+ * and vLevel is equal or greater than the visiblity level
+ * and fLevel is equal or greater then the facility code level.
+ * @param dLevel The debug finer level to check for.
+ * @param vLevel The debug visibilty level to check for.
+ * @param fLevel The facility code level to check for.
+ */
+ public boolean debugAllowed(long dLevel, long vLevel, long fLevel)
+ {
+ return (((dLevel & m_debugLevel) != 0) &&
+ ((vLevel & m_visLevel) != 0) &&
+ ((fLevel & m_facLevel) != 0));
+ }
+
+ /**********************************************************************************************************
+ * Finer-Granularity Debug Methods.
+ **********************************************************************************************************/
+
+ /**
+ * Log a message with the DEBUG Level and with finer granularity and with arguments. The debug message
+ * is sent to the output only if the specified debug level, visibility level, and facility code
+ * match those allowed by the logger.
+ * @param dl The debug finer level associated with the log message. That is, the logger object allows
+ * to log only if the DEBUG level is allowed and dl is either equals or greater the debug level assigned to
+ * the logger Object
+ * @param vl The visibility level associated with the log message. That is, the logger object allows
+ * to log only if the DEBUG level is allowed and vl is either equals or greater the visibility level assigned to
+ * the logger Object
+ * @param fl The facility code level associated with the log message. That is, the logger object allows
+ * to log only if the DEBUG level is allowed and fl is either equals or greater the facility code level assigned to
+ * the logger Object
+ * @param key resource bundle key for the message to log
+ * @param params parameters passed to the message
+ */
+ public void debug(long dl, long vl, long fl, String key, Object[] params)
+ {
+ if (debugAllowed(dl, vl, fl))
+ {
+ debug(key, params);
+ }
+ }
+
+ /**
+ * Log a message with the DEBUG Level and with finer granularity.
+ * The debug message is sent to the output only if the specified debug level, visibility level,
+ * and facility code match those allowed by the logger.
+ * @param dl The debug finer level associated with the log message. That is, the logger object allows
+ * to log only if the DEBUG level is allowed and dl is either equals or greater the debug level assigned to
+ * the logger Object
+ * @param vl The visibility level associated with the log message. That is, the logger object allows
+ * to log only if the DEBUG level is allowed and vl is either equals or greater the visibility level assigned to
+ * the logger Object
+ * @param fl The facility code level associated with the log message. That is, the logger object allows
+ * to log only if the DEBUG level is allowed and fl is either equals or greater the facility code level assigned to
+ * the logger Object
+ * @param key resource bundle key for the message to log
+ */
+ public void debug(long dl, long vl, long fl, String key)
+ {
+ if (debugAllowed(dl, vl, fl))
+ {
+ debug(key);
+ }
+
+ }
+
+ /**
+ * Log a message with the DEBUG Level and with finer granularity and throwable message.
+ * The debug message is sent to the output only if the specified debug level, visibility level,
+ * and facility code match those allowed by the logger.
+ * @param dl The debug finer level associated with the log message. That is, the logger object allows
+ * to log only if the DEBUG level is allowed and dl is either equals or greater the debug level assigned to
+ * the logger Object
+ * @param vl The visibility level associated with the log message. That is, the logger object allows
+ * to log only if the DEBUG level is allowed and vl is either equals or greater the visibility level assigned to
+ * the logger Object
+ * @param fl The facility code level associated with the log message. That is, the logger object allows
+ * to log only if the DEBUG level is allowed and fl is either equals or greater the facility code level assigned to
+ * the logger Object
+ * @param key resource bundle key for the message to log
+ * @param throwable Throwable associated with the log message
+ */
+ public void debug(long dl, long vl, long fl, String key, Throwable throwable)
+ {
+ if (debugAllowed(dl, vl, fl))
+ {
+ debug(key, throwable);
+ }
+ }
+
+ /**
+ * Log a message with the DEBUG Level and with finer granularity, arguments and throwable message.
+ * The debug message is sent to the output only if the specified debug level, visibility level,
+ * and facility code match those allowed by the logger.
+ * @param dl The debug finer level associated with the log message. That is, the logger object allows
+ * to log only if the DEBUG level is allowed and dl is either equals or greater the debug level assigned to
+ * the logger Object
+ * @param vl The visibility level associated with the log message. That is, the logger object allows
+ * to log only if the DEBUG level is allowed and vl is either equals or greater the visibility level assigned to
+ * the logger Object
+ * @param fl The facility code level associated with the log message. That is, the logger object allows
+ * to log only if the DEBUG level is allowed and fl is either equals or greater the facility code level assigned to
+ * the logger Object
+ * @param key resource bundle key for the message to log
+ * @param params parameters passed to the message
+ * @param throwable Throwable associated with the log message
+ */
+ public void debug(long dl, long vl, long fl, String key, Object[] params, Throwable throwable)
+ {
+ if (debugAllowed(dl, vl, fl))
+ {
+ debug(key, params, throwable);
+ }
+ }
+
+
+ /**********************************************************************************************************/
+ /* RESOURCE BUNDLE EVALUATION */
+ /**********************************************************************************************************/
+
+ /**
+ * Obtain a localized message from one of the resource bundles associated
+ * with this logger.
+ *
+ * The user supplied parameter <code>key</code> is replaced by its localized
+ * version from the resource bundle.
+ *
+ * @param key unique key to identify an entry in the resource bundle.
+ * @return The localised string according to user's locale and available resource bundles. placeholder message
+ * if the resource bundle or key cannot be found.
+ */
+ public String getString(String key)
+ {
+ try
+ {
+ return getResourceBundleString(key);
+ }
+ catch (MissingResourceException mre)
+ {
+ return mre.getLocalizedMessage() + ": [key='" + key + "']";
+ }
+ }
+
+ /**
+ * Obtain a localized and parameterized message from one of the resource
+ * bundles associated with this logger.
+ *
+ * First, the user supplied <code>key</code> is searched in the resource
+ * bundle. Next, the resulting pattern is formatted using
+ * {@link java.text.MessageFormat#format(String,Object[])} method with the
+ * user supplied object array <code>params</code>.
+ *
+ * @param key unique key to identify an entry in the resource bundle.
+ * @param params parameters to fill placeholders (e.g., {0}, {1}) in the resource bundle string.
+ * @return The localised string according to user's locale and available resource bundles. placeholder message
+ * if the resource bundle or key cannot be found.
+ */
+ public String getString(String key, Object[] params)
+ {
+ try
+ {
+ String pattern = getResourceBundleString(key);
+ return java.text.MessageFormat.format(pattern, params);
+ }
+ catch (MissingResourceException mre)
+ {
+ StringBuffer sb = new StringBuffer();
+ for(Object param : params) {
+ sb.append(param);
+ sb.append( ", ");
+ }
+ return mre.getLocalizedMessage() + ": [key='" + key + "']" + sb.toString();
+ }
+ }
+
+ /**
+ *
+ * @param key the message key
+ * @return the resource bundle String
+ * @throws MissingResourceException if the default bundle is not set
+ */
+ synchronized String getResourceBundleString(String key) throws MissingResourceException
+ {
+ String resource = null;
+ if (m_defaultResourceBundle == null)
+ {
+ throw new MissingResourceException("no default resource bundle set for this logger", null, null);
+ }
+ else
+ {
+ try
+ {
+ resource = m_defaultResourceBundle.getString(key);
+ }
+ // this exception will occur if no resource for the given key can be found.
+ catch (MissingResourceException mre)
+ {
+ // if no extra res bundles are available, that's it. bail out!
+ if (m_extraResourceBundles == null)
+ {
+ throw mre;
+ }
+ else
+ {
+ for (ResourceBundle bundle : m_extraResourceBundles)
+ {
+ try
+ {
+ resource = bundle.getString(key);
+ }
+ catch (MissingResourceException mre2)
+ {
+ mre = mre2;
+ }
+ }
+ // if no resource for the given key could be found in any of the
+ // resource bundles, throw an exception.
+ if (resource == null)
+ {
+ throw mre;
+ }
+ }
+ }
+ }
+ return resource;
+ }
+
+ /**
+ * Log a message with DEBUG Level
+ *
+ * @param key resource bundle key for the message to log
+ *
+ * @deprecated use debug (String key, null) instead
+ */
+ public void debug(String key)
+ {
+ if (!isDebugEnabled()) return;
+ String message = evalResourceBundle(key);
+ m_logInterface.debug(message);
+ }
+
+ /**
+ * Log a message with the DEBUG Level and with a throwable arguments
+ * @param key resource bundle key for the message to log
+ * @param throwable The Throwable to log
+ */
+ public void debug(String key, Throwable throwable)
+ {
+ if (!isDebugEnabled()) return;
+ String message = evalResourceBundle(key);
+ m_logInterface.debug(message, throwable);
+ }
+
+ /**
+ * Log a message with DEBUG Level and with arguments
+ *
+ * @param key resource bundle key for the message to log
+ * @param params parameters passed to the message
+ */
+ public void debug(String key, Object[] params)
+ {
+ if (!isDebugEnabled()) return;
+ String message = evalResourceBundle(key, params);
+ m_logInterface.debug(message);
+ }
+
+ /**
+ * Log a message with DEBUG Level, with arguments and with a throwable arguments
+ *
+ * @param key resource bundle key for the message to log
+ * @param params parameters passed to the message
+ * @param throwable The Throwable to log
+ */
+ public void debug(String key, Object[] params, Throwable throwable)
+ {
+ if (!isDebugEnabled()) return;
+ String message = evalResourceBundle(key, params);
+ m_logInterface.debug(message, throwable);
+ }
+
+ /**
+ * Log a message with INFO Level
+ *
+ * @param key resource bundle key for the message to log
+ *
+ * @deprecated use info (String key, null) instead
+ */
+ public void info(String key)
+ {
+ if (!isInfoEnabled()) return;
+ String message = evalResourceBundle(key);
+ m_logInterface.info(message);
+ }
+
+ /**
+ * Log a message with the INFO Level and with a throwable arguments
+ * @param key resource bundle key for the message to log
+ * @param throwable Throwable associated to the logging message
+ */
+ public void info(String key, Throwable throwable)
+ {
+ if (!isInfoEnabled()) return;
+ String message = evalResourceBundle(key);
+ m_logInterface.info(message, throwable);
+ }
+
+ /**
+ * Log a message with the INFO Level and with arguments
+ * @param key resource bundle key for the message to log
+ * @param params parameters passed to the message
+ */
+ public void info(String key, Object[] params)
+ {
+ if (!isInfoEnabled()) return;
+ String message = evalResourceBundle(key, params);
+ m_logInterface.info(message);
+ }
+
+ /**
+ * Log a message with the INFO Level, with arguments and with a throwable arguments
+ * @param key resource bundle key for the message to log
+ * @param params parameters passed to the message
+ * @param throwable Throwable associated with the logging request
+ */
+ public void info(String key, Object[] params, Throwable throwable)
+ {
+ if (!isInfoEnabled()) return;
+ String message = evalResourceBundle(key, params);
+ m_logInterface.info(message, throwable);
+ }
+
+ /**
+ * Log a message with the WARN Level
+ * @param key resource bundle key for the message to log
+ *
+ * @deprecated use warn (String key, null) instead
+ */
+ public void warn(String key)
+ {
+ if (!isWarnEnabled()) return;
+ String message = evalResourceBundle(key);
+ m_logInterface.warn(message);
+ }
+
+ /**
+ * Log a message with the WARN Level and with a throwable arguments
+ * @param key resource bundle key for the message to log
+ * @param throwable Throwable associated with the logging request
+ */
+ public void warn(String key, Throwable throwable)
+ {
+ if (!isWarnEnabled()) return;
+ String message = evalResourceBundle(key);
+ m_logInterface.warn(message, throwable);
+ }
+
+ /**
+ * Log a message with the WARN Level and with arguments
+ * @param key resource bundle key for the message to log
+ * @param params parameters passed to the message
+ */
+ public void warn(String key, Object[] params)
+ {
+ if (!isWarnEnabled()) return;
+ String message = evalResourceBundle(key, params);
+ m_logInterface.warn(message);
+ }
+
+ /**
+ * Log a message with the WARN Level, with arguments and with a throwable arguments
+ * @param key resource bundle key for the message to log
+ * @param params parameters passed to the message
+ * @param throwable Throwable associated with the logging request
+ */
+ public void warn(String key, Object[] params, Throwable throwable)
+ {
+ if (!isWarnEnabled()) return;
+ String message = evalResourceBundle(key, params);
+ m_logInterface.warn(message, throwable);
+ }
+
+ /**
+ * Log a message with the ERROR Level
+ * @param key resource bundle key for the message to log
+ *
+ * @deprecated use error (String key, null) instead
+ */
+ public void error(String key)
+ {
+ if (!isErrorEnabled()) return;
+ String message = evalResourceBundle(key);
+ m_logInterface.error(message);
+ }
+
+ /**
+ * Log a message with the ERROR Level and with a throwable arguments
+ * @param key resource bundle key for the message to log
+ * @param throwable Throwable associated with the logging request
+ */
+ public void error(String key, Throwable throwable)
+ {
+ if (!isErrorEnabled()) return;
+ String message = evalResourceBundle(key);
+ m_logInterface.error(message, throwable);
+ }
+
+ /**
+ * Log a message with the ERROR Level and with arguments
+ * @param key resource bundle key for the message to log
+ * @param params parameters passed to the message
+ */
+ public void error(String key, Object[] params)
+ {
+ if (!isErrorEnabled()) return;
+ String message = evalResourceBundle(key, params);
+ m_logInterface.error(message);
+ }
+
+ /**
+ * Log a message with the ERROR Level, with arguments and with a throwable arguments
+ * @param key resource bundle key for the message to log
+ * @param params parameters passed to the message
+ * @param throwable Throwable associated with the logging request
+ */
+ public void error(String key, Object[] params, Throwable throwable)
+ {
+ if (!isErrorEnabled()) return;
+ String message = evalResourceBundle(key, params);
+ m_logInterface.error(message, throwable);
+ }
+
+ /**
+ * Log a message with the FATAL Level
+ * @param key resource bundle key for the message to log
+ *
+ * @deprecated use fatal (String key, null) instead
+ */
+ public void fatal(String key)
+ {
+ if (!isFatalEnabled()) return;
+ String message = evalResourceBundle(key);
+ m_logInterface.fatal(message);
+ }
+
+ /**
+ * Log a message with the FATAL Level and with a throwable arguments
+ * @param key resource bundle key for the message to log
+ * @param throwable Throwable associated with the logging request
+ */
+ public void fatal(String key, Throwable throwable)
+ {
+ if (!isFatalEnabled()) return;
+ String message = evalResourceBundle(key);
+ m_logInterface.fatal(message, throwable);
+ }
+
+ /**
+ * Log a message with the FATAL Level and with arguments
+ * @param key resource bundle key for the message to log
+ * @param params parameters passed to the message
+ */
+ public void fatal(String key, Object[] params)
+ {
+ if (!isFatalEnabled()) return;
+ String message = evalResourceBundle(key, params);
+ m_logInterface.fatal(message);
+ }
+
+ /**
+ * Log a message with the FATAL Level, with arguments and with a throwable arguments
+ * @param key resource bundle key for the message to log
+ * @param params parameters passed to the message
+ * @param throwable Throwable associated with the logging request
+ */
+ public void fatal(String key, Object[] params, Throwable throwable)
+ {
+ if (!isFatalEnabled()) return;
+ String message = evalResourceBundle(key, params);
+ m_logInterface.fatal(message, throwable);
+ }
+
+ // -------------------------------------------------------------------------------------
+ // private methods
+ // -------------------------------------------------------------------------------------
+
+ private String evalResourceBundle(String key)
+ {
+ return getString(key);
+ }
+
+ private String evalResourceBundle(String key, Object[] params)
+ {
+ return getString(key, params);
+ }
+}
Copied: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/basic/BasicLog.java (from rev 29850, labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/DefaultLog.java)
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/basic/BasicLog.java (rev 0)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/basic/BasicLog.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -0,0 +1,601 @@
+/*
+ * This file has been copied from the Apache Commons Logging project
+ * release version 1.1.0 and then modified.
+ * It was formerly called org.apache.commons.logging.impl.SimpleLog.
+ *
+ * Apart from the package and class name changes, the modifications
+ * relate to configuration properties and use of a file rather than
+ * System.out for default logging.
+ */
+
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * 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.apache.commons.logging.impl; // apache version
+package com.arjuna.common.internal.util.logging.basic;
+
+import com.arjuna.common.internal.util.logging.LogInterface;
+import com.arjuna.common.internal.util.logging.commonPropertyManager;
+
+import java.io.Serializable;
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Properties;
+
+
+/**
+ * <p>Simple implementation of Log that sends all enabled log messages,
+ * for all defined loggers, to System.err. The following system properties
+ * are supported to configure the behavior of this logger:</p>
+ * <ul>
+ * <li><code>org.apache.commons.logging.simplelog.defaultlog</code> -
+ * Default logging detail level for all instances of SimpleLog.
+ * Must be one of ("trace", "debug", "info", "warn", "error", or "fatal").
+ * If not specified, defaults to "info". </li>
+ * <li><code>org.apache.commons.logging.simplelog.log.xxxxx</code> -
+ * Logging detail level for a SimpleLog instance named "xxxxx".
+ * Must be one of ("trace", "debug", "info", "warn", "error", or "fatal").
+ * If not specified, the default logging detail level is used.</li>
+ * <li><code>org.apache.commons.logging.simplelog.showlogname</code> -
+ * Set to <code>true</code> if you want the Log instance name to be
+ * included in output messages. Defaults to <code>false</code>.</li>
+ * <li><code>org.apache.commons.logging.simplelog.showShortLogname</code> -
+ * Set to <code>true</code> if you want the last component of the name to be
+ * included in output messages. Defaults to <code>true</code>.</li>
+ * <li><code>org.apache.commons.logging.simplelog.showdatetime</code> -
+ * Set to <code>true</code> if you want the current date and time
+ * to be included in output messages. Default is <code>false</code>.</li>
+ * <li><code>org.apache.commons.logging.simplelog.dateTimeFormat</code> -
+ * The date and time format to be used in the output messages.
+ * The pattern describing the date and time format is the same that is
+ * used in <code>java.text.SimpleDateFormat</code>. If the format is not
+ * specified or is invalid, the default format is used.
+ * The default format is <code>yyyy/MM/dd HH:mm:ss:SSS zzz</code>.</li>
+ * </ul>
+ *
+ * <p>In addition to looking for system properties with the names specified
+ * above, this implementation also checks for a class loader resource named
+ * <code>"simplelog.properties"</code>, and includes any matching definitions
+ * from this resource (if it exists).</p>
+ *
+ * @author <a href="mailto:sanders at apache.org">Scott Sanders</a>
+ * @author Rod Waldhoff
+ * @author Robert Burrell Donkin
+ *
+ * @version (apache version) Id: SimpleLog.java 399221 2006-05-03 09:20:24Z dennisl
+ */
+public class BasicLog implements Serializable, LogInterface
+{
+ // ------------------------------------------------------- Class Attributes
+
+ /** Properties loaded from simplelog.properties */
+ static protected final Properties simpleLogProps = new Properties();
+
+ /** The default format to use when formating dates */
+ static protected final String DEFAULT_DATE_TIME_FORMAT =
+ "yyyy/MM/dd HH:mm:ss:SSS zzz";
+
+ /** Include the instance name in the log message? */
+ static protected boolean showLogName = false;
+ /** Include the short name ( last component ) of the logger in the log
+ * message. Defaults to true - otherwise we'll be lost in a flood of
+ * messages without knowing who sends them.
+ */
+ static protected boolean showShortName = true;
+ /** Include the current time in the log message */
+ static protected boolean showDateTime = true;
+ /** The date and time format to use in the log message */
+ static protected String dateTimeFormat = DEFAULT_DATE_TIME_FORMAT;
+ /** Used to format times */
+ static protected DateFormat dateFormatter = null;
+
+ static PrintStream defaultLogFile = null;
+
+ // ---------------------------------------------------- Log Level Constants
+
+
+ /** "Trace" level logging. */
+ public static final int LOG_LEVEL_TRACE = 1;
+ /** "Debug" level logging. */
+ public static final int LOG_LEVEL_DEBUG = 2;
+ /** "Info" level logging. */
+ public static final int LOG_LEVEL_INFO = 3;
+ /** "Warn" level logging. */
+ public static final int LOG_LEVEL_WARN = 4;
+ /** "Error" level logging. */
+ public static final int LOG_LEVEL_ERROR = 5;
+ /** "Fatal" level logging. */
+ public static final int LOG_LEVEL_FATAL = 6;
+
+ /** Enable all logging levels */
+ public static final int LOG_LEVEL_ALL = (LOG_LEVEL_TRACE - 1);
+
+ /** Enable no logging levels */
+ public static final int LOG_LEVEL_OFF = (LOG_LEVEL_FATAL + 1);
+
+ // ------------------------------------------------------------ Initializer
+
+ // Initialize class attributes.
+ // Load properties file, if found.
+ // Override with system properties.
+ static {
+
+ showLogName = commonPropertyManager.getBasicLogEnvironmentBean().isShowLogName();
+ showShortName = commonPropertyManager.getBasicLogEnvironmentBean().isShowShortLogName();
+ showDateTime = commonPropertyManager.getBasicLogEnvironmentBean().isShowDate();
+ dateFormatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss:SSS zzz");
+
+ String fileName = commonPropertyManager.getBasicLogEnvironmentBean().getLogFile();
+ boolean fileAppend = commonPropertyManager.getBasicLogEnvironmentBean().isLogFileAppend();
+ try {
+ FileOutputStream fOut = new FileOutputStream(fileName, fileAppend);
+ defaultLogFile = new PrintStream(fOut, true);
+ defaultLogFile.println();
+ defaultLogFile.println();
+ defaultLogFile.println("---------------------------------------------------------------");
+ defaultLogFile.println("DEFAULT LOG, started " + dateFormatter.format(new Date()));
+ defaultLogFile.println("---------------------------------------------------------------");
+ }
+ catch (Exception e)
+ {
+ System.err.println("cannot set up default log for error messages to file " + fileName + ": " + e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
+
+ // ------------------------------------------------------------- Attributes
+
+ /** The name of this simple log instance */
+ protected String logName = null;
+ /** The current log level */
+ protected int currentLogLevel;
+ /** The short name of this simple log instance */
+ private String shortLogName = null;
+
+
+ // ------------------------------------------------------------ Constructor
+
+ /**
+ * Construct a simple log with given name.
+ *
+ * @param name log name
+ */
+ public BasicLog(String name) {
+
+ logName = name;
+
+ // Set initial log level
+ // Used to be: set default log level to ERROR
+ // IMHO it should be lower, but at least info ( costin ).
+ setLevel(BasicLog.LOG_LEVEL_INFO);
+
+ // Set log level from properties
+ String lvl = commonPropertyManager.getBasicLogEnvironmentBean().getDefaultLevel();
+
+ if("all".equalsIgnoreCase(lvl)) {
+ setLevel(BasicLog.LOG_LEVEL_ALL);
+ } else if("trace".equalsIgnoreCase(lvl)) {
+ setLevel(BasicLog.LOG_LEVEL_TRACE);
+ } else if("debug".equalsIgnoreCase(lvl)) {
+ setLevel(BasicLog.LOG_LEVEL_DEBUG);
+ } else if("info".equalsIgnoreCase(lvl)) {
+ setLevel(BasicLog.LOG_LEVEL_INFO);
+ } else if("warn".equalsIgnoreCase(lvl)) {
+ setLevel(BasicLog.LOG_LEVEL_WARN);
+ } else if("error".equalsIgnoreCase(lvl)) {
+ setLevel(BasicLog.LOG_LEVEL_ERROR);
+ } else if("fatal".equalsIgnoreCase(lvl)) {
+ setLevel(BasicLog.LOG_LEVEL_FATAL);
+ } else if("off".equalsIgnoreCase(lvl)) {
+ setLevel(BasicLog.LOG_LEVEL_OFF);
+ }
+
+ }
+
+
+ // -------------------------------------------------------- Properties
+
+ /**
+ * <p> Set logging level. </p>
+ *
+ * @param currentLogLevel new logging level
+ */
+ public void setLevel(int currentLogLevel) {
+
+ this.currentLogLevel = currentLogLevel;
+
+ }
+
+
+ /**
+ * <p> Get logging level. </p>
+ * @return the current logging level
+ */
+ public int getLevel() {
+
+ return currentLogLevel;
+ }
+
+
+ // -------------------------------------------------------- Logging Methods
+
+
+ /**
+ * <p> Do the actual logging.
+ * This method assembles the message
+ * and then calls <code>write()</code> to cause it to be written.</p>
+ *
+ * @param type One of the LOG_LEVEL_XXX constants defining the log level
+ * @param message The message itself (typically a String)
+ * @param t The exception whose stack trace should be logged
+ */
+ protected void log(int type, Object message, Throwable t) {
+ // Use a string buffer for better performance
+ StringBuffer buf = new StringBuffer();
+
+ // Append date-time if so configured
+ if(showDateTime) {
+ buf.append(dateFormatter.format(new Date()));
+ buf.append(" ");
+ }
+
+ // Append a readable representation of the log level
+ switch(type) {
+ case BasicLog.LOG_LEVEL_TRACE: buf.append("[TRACE] "); break;
+ case BasicLog.LOG_LEVEL_DEBUG: buf.append("[DEBUG] "); break;
+ case BasicLog.LOG_LEVEL_INFO: buf.append("[INFO] "); break;
+ case BasicLog.LOG_LEVEL_WARN: buf.append("[WARN] "); break;
+ case BasicLog.LOG_LEVEL_ERROR: buf.append("[ERROR] "); break;
+ case BasicLog.LOG_LEVEL_FATAL: buf.append("[FATAL] "); break;
+ }
+
+ // Append the name of the log instance if so configured
+ if( showShortName) {
+ if( shortLogName==null ) {
+ // Cut all but the last component of the name for both styles
+ shortLogName = logName.substring(logName.lastIndexOf(".") + 1);
+ shortLogName =
+ shortLogName.substring(shortLogName.lastIndexOf("/") + 1);
+ }
+ buf.append(String.valueOf(shortLogName)).append(" - ");
+ } else if(showLogName) {
+ buf.append(String.valueOf(logName)).append(" - ");
+ }
+
+ // Append the message
+ buf.append(String.valueOf(message));
+
+ // Append stack trace if not null
+ if(t != null) {
+ buf.append(" <");
+ buf.append(t.toString());
+ buf.append(">");
+
+ java.io.StringWriter sw= new java.io.StringWriter(1024);
+ java.io.PrintWriter pw= new java.io.PrintWriter(sw);
+ t.printStackTrace(pw);
+ pw.close();
+ buf.append(sw.toString());
+ }
+
+ // Print to the appropriate destination
+ write(buf);
+
+ }
+
+
+ /**
+ * <p>Write the content of the message accumulated in the specified
+ * <code>StringBuffer</code> to the appropriate output destination. The
+ * default implementation writes to <code>System.err</code>.</p>
+ *
+ * @param buffer A <code>StringBuffer</code> containing the accumulated
+ * text to be logged
+ */
+ protected void write(StringBuffer buffer) {
+
+ // print to log file.
+ defaultLogFile.println(buffer.toString());
+
+ }
+
+
+ /**
+ * Is the given log level currently enabled?
+ *
+ * @param logLevel is this level enabled?
+ * @return true is enabled, false otherwise
+ */
+ protected boolean isLevelEnabled(int logLevel) {
+ // log level are numerically ordered so can use simple numeric
+ // comparison
+ return (logLevel >= currentLogLevel);
+ }
+
+
+ // -------------------------------------------------------- Log Implementation
+
+
+ /**
+ * Logs a message with
+ * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_DEBUG</code>.
+ *
+ * @param message to log
+ * @see org.apache.commons.logging.Log#debug(Object)
+ */
+ public final void debug(Object message) {
+
+ if (isLevelEnabled(BasicLog.LOG_LEVEL_DEBUG)) {
+ log(BasicLog.LOG_LEVEL_DEBUG, message, null);
+ }
+ }
+
+
+ /**
+ * Logs a message with
+ * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_DEBUG</code>.
+ *
+ * @param message to log
+ * @param t log this cause
+ * @see org.apache.commons.logging.Log#debug(Object, Throwable)
+ */
+ public final void debug(Object message, Throwable t) {
+
+ if (isLevelEnabled(BasicLog.LOG_LEVEL_DEBUG)) {
+ log(BasicLog.LOG_LEVEL_DEBUG, message, t);
+ }
+ }
+
+
+ /**
+ * Logs a message with
+ * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_TRACE</code>.
+ *
+ * @param message to log
+ * @see org.apache.commons.logging.Log#trace(Object)
+ */
+ public final void trace(Object message) {
+
+ if (isLevelEnabled(BasicLog.LOG_LEVEL_TRACE)) {
+ log(BasicLog.LOG_LEVEL_TRACE, message, null);
+ }
+ }
+
+
+ /**
+ * Logs a message with
+ * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_TRACE</code>.
+ *
+ * @param message to log
+ * @param t log this cause
+ * @see org.apache.commons.logging.Log#trace(Object, Throwable)
+ */
+ public final void trace(Object message, Throwable t) {
+
+ if (isLevelEnabled(BasicLog.LOG_LEVEL_TRACE)) {
+ log(BasicLog.LOG_LEVEL_TRACE, message, t);
+ }
+ }
+
+
+ /**
+ * Logs a message with
+ * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_INFO</code>.
+ *
+ * @param message to log
+ * @see org.apache.commons.logging.Log#info(Object)
+ */
+ public final void info(Object message) {
+
+ if (isLevelEnabled(BasicLog.LOG_LEVEL_INFO)) {
+ log(BasicLog.LOG_LEVEL_INFO,message,null);
+ }
+ }
+
+
+ /**
+ * Logs a message with
+ * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_INFO</code>.
+ *
+ * @param message to log
+ * @param t log this cause
+ * @see org.apache.commons.logging.Log#info(Object, Throwable)
+ */
+ public final void info(Object message, Throwable t) {
+
+ if (isLevelEnabled(BasicLog.LOG_LEVEL_INFO)) {
+ log(BasicLog.LOG_LEVEL_INFO, message, t);
+ }
+ }
+
+
+ /**
+ * Logs a message with
+ * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_WARN</code>.
+ *
+ * @param message to log
+ * @see org.apache.commons.logging.Log#warn(Object)
+ */
+ public final void warn(Object message) {
+
+ if (isLevelEnabled(BasicLog.LOG_LEVEL_WARN)) {
+ log(BasicLog.LOG_LEVEL_WARN, message, null);
+ }
+ }
+
+
+ /**
+ * Logs a message with
+ * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_WARN</code>.
+ *
+ * @param message to log
+ * @param t log this cause
+ * @see org.apache.commons.logging.Log#warn(Object, Throwable)
+ */
+ public final void warn(Object message, Throwable t) {
+
+ if (isLevelEnabled(BasicLog.LOG_LEVEL_WARN)) {
+ log(BasicLog.LOG_LEVEL_WARN, message, t);
+ }
+ }
+
+
+ /**
+ * Logs a message with
+ * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_ERROR</code>.
+ *
+ * @param message to log
+ * @see org.apache.commons.logging.Log#error(Object)
+ */
+ public final void error(Object message) {
+
+ if (isLevelEnabled(BasicLog.LOG_LEVEL_ERROR)) {
+ log(BasicLog.LOG_LEVEL_ERROR, message, null);
+ }
+ }
+
+
+ /**
+ * Logs a message with
+ * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_ERROR</code>.
+ *
+ * @param message to log
+ * @param t log this cause
+ * @see org.apache.commons.logging.Log#error(Object, Throwable)
+ */
+ public final void error(Object message, Throwable t) {
+
+ if (isLevelEnabled(BasicLog.LOG_LEVEL_ERROR)) {
+ log(BasicLog.LOG_LEVEL_ERROR, message, t);
+ }
+ }
+
+
+ /**
+ * Log a message with
+ * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_FATAL</code>.
+ *
+ * @param message to log
+ * @see org.apache.commons.logging.Log#fatal(Object)
+ */
+ public final void fatal(Object message) {
+
+ if (isLevelEnabled(BasicLog.LOG_LEVEL_FATAL)) {
+ log(BasicLog.LOG_LEVEL_FATAL, message, null);
+ }
+ }
+
+
+ /**
+ * Logs a message with
+ * <code>org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_FATAL</code>.
+ *
+ * @param message to log
+ * @param t log this cause
+ * @see org.apache.commons.logging.Log#fatal(Object, Throwable)
+ */
+ public final void fatal(Object message, Throwable t) {
+
+ if (isLevelEnabled(BasicLog.LOG_LEVEL_FATAL)) {
+ log(BasicLog.LOG_LEVEL_FATAL, message, t);
+ }
+ }
+
+
+ /**
+ * <p> Are debug messages currently enabled? </p>
+ *
+ * <p> This allows expensive operations such as <code>String</code>
+ * concatenation to be avoided when the message will be ignored by the
+ * logger. </p>
+ */
+ public final boolean isDebugEnabled() {
+
+ return isLevelEnabled(BasicLog.LOG_LEVEL_DEBUG);
+ }
+
+
+ /**
+ * <p> Are error messages currently enabled? </p>
+ *
+ * <p> This allows expensive operations such as <code>String</code>
+ * concatenation to be avoided when the message will be ignored by the
+ * logger. </p>
+ */
+ public final boolean isErrorEnabled() {
+
+ return isLevelEnabled(BasicLog.LOG_LEVEL_ERROR);
+ }
+
+
+ /**
+ * <p> Are fatal messages currently enabled? </p>
+ *
+ * <p> This allows expensive operations such as <code>String</code>
+ * concatenation to be avoided when the message will be ignored by the
+ * logger. </p>
+ */
+ public final boolean isFatalEnabled() {
+
+ return isLevelEnabled(BasicLog.LOG_LEVEL_FATAL);
+ }
+
+
+ /**
+ * <p> Are info messages currently enabled? </p>
+ *
+ * <p> This allows expensive operations such as <code>String</code>
+ * concatenation to be avoided when the message will be ignored by the
+ * logger. </p>
+ */
+ public final boolean isInfoEnabled() {
+
+ return isLevelEnabled(BasicLog.LOG_LEVEL_INFO);
+ }
+
+
+ /**
+ * <p> Are trace messages currently enabled? </p>
+ *
+ * <p> This allows expensive operations such as <code>String</code>
+ * concatenation to be avoided when the message will be ignored by the
+ * logger. </p>
+ */
+ public final boolean isTraceEnabled() {
+
+ return isLevelEnabled(BasicLog.LOG_LEVEL_TRACE);
+ }
+
+
+ /**
+ * <p> Are warn messages currently enabled? </p>
+ *
+ * <p> This allows expensive operations such as <code>String</code>
+ * concatenation to be avoided when the message will be ignored by the
+ * logger. </p>
+ */
+ public final boolean isWarnEnabled() {
+
+ return isLevelEnabled(BasicLog.LOG_LEVEL_WARN);
+ }
+}
+
Copied: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/basic/BasicLogEnvironmentBean.java (from rev 29850, labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/DefaultLogEnvironmentBean.java)
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/basic/BasicLogEnvironmentBean.java (rev 0)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/basic/BasicLogEnvironmentBean.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -0,0 +1,181 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2009,
+ * @author JBoss, a division of Red Hat.
+ */
+package com.arjuna.common.internal.util.logging.basic;
+
+import com.arjuna.common.internal.util.propertyservice.PropertyPrefix;
+
+/**
+ * A JavaBean containing configuration properties for the built-in log system.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com)
+ */
+ at PropertyPrefix(prefix = "com.arjuna.common.util.logging.default.")
+public class BasicLogEnvironmentBean
+{
+ private volatile boolean showLogName = false;
+ private volatile boolean showShortLogName = true;
+ private volatile boolean showDate = true;
+ private volatile boolean logFileAppend = true;
+
+ private volatile String defaultLevel = "info";
+
+ private volatile String logFile = "error.log";
+
+
+ /**
+ * Returns true if the log output should contain the log name element.
+ *
+ * Default: false
+ * Equivalent deprecated property: com.arjuna.common.util.logging.default.showLogName
+ *
+ * @return true if the log name should appear in the log output, false otherwise.
+ */
+ public boolean isShowLogName()
+ {
+ return showLogName;
+ }
+
+ /**
+ * Enables the use of the log name element in log output.
+ *
+ * @param showLogName true if the log name should appear in the log output, false otherwise.
+ */
+ public void setShowLogName(boolean showLogName)
+ {
+ this.showLogName = showLogName;
+ }
+
+ /**
+ * Returns true if the log output should contain the short form log name element.
+ *
+ * Default: true
+ * Equivalent deprecated property: com.arjuna.common.util.logging.default.showShortLogName
+ *
+ * @return true if the short log name should appear in the log output, false otherwise.
+ */
+ public boolean isShowShortLogName()
+ {
+ return showShortLogName;
+ }
+
+ /**
+ * Enables use of the short log name element in log output.
+ *
+ * @param showShortLogName true if the log name should appear in the log output, false otherwise.
+ */
+ public void setShowShortLogName(boolean showShortLogName)
+ {
+ this.showShortLogName = showShortLogName;
+ }
+
+ /**
+ * Returns true if the log output should contain the date/time element.
+ *
+ * Default: true
+ * Equivalent deprecated property: com.arjuna.common.util.logging.default.showDate
+ *
+ * @return true if the date/time should appear in the log output, false otherwise.
+ */
+ public boolean isShowDate()
+ {
+ return showDate;
+ }
+
+ /**
+ * Enables use of the date/time element in log output.
+ *
+ * @param showDate true if the date/time should appear in log output, false otherwise.
+ */
+ public void setShowDate(boolean showDate)
+ {
+ this.showDate = showDate;
+ }
+
+ /**
+ * Returns true if the log file should be appended to.
+ *
+ * Default: true
+ * Equivalent deprecated property: com.arjuna.common.util.logging.default.logFileAppend
+ *
+ * @return true if append behaviour is required, false for overwrite behaviour.
+ */
+ public boolean isLogFileAppend()
+ {
+ return logFileAppend;
+ }
+
+ /**
+ * Enables appending to an existing log file rather than overwiting it.
+ *
+ * @param logFileAppend true for appending, false otherwise.
+ */
+ public void setLogFileAppend(boolean logFileAppend)
+ {
+ this.logFileAppend = logFileAppend;
+ }
+
+ /**
+ * Returns the threshold level for logging.
+ *
+ * Default: "info"
+ * Equivalent deprecated property: com.arjuna.common.util.logging.default.defaultLevel
+ *
+ * @return the default threshold logging level.
+ */
+ public String getDefaultLevel()
+ {
+ return defaultLevel;
+ }
+
+ /**
+ * Sets the default log threshold.
+ * Valid values (in order) are: all, trace, debug, info, warn, error, fatal, off
+ *
+ * @param defaultLevel the default log threshold.
+ */
+ public void setDefaultLevel(String defaultLevel)
+ {
+ this.defaultLevel = defaultLevel;
+ }
+
+ /**
+ * Returns the name of the log file to use.
+ *
+ * Default: "error.log"
+ * Equivalent deprecated property: com.arjuna.common.util.logging.default.logFile
+ *
+ * @return the name of the file to which the log statements will be written.
+ */
+ public String getLogFile()
+ {
+ return logFile;
+ }
+
+ /**
+ * Sets the name of the log file to write output to.
+ *
+ * @param logFile the filename, relative or absolute.
+ */
+ public void setLogFile(String logFile)
+ {
+ this.logFile = logFile;
+ }
+}
Added: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/basic/BasicLogFactory.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/basic/BasicLogFactory.java (rev 0)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/basic/BasicLogFactory.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2009,
+ * @author JBoss, a division of Red Hat.
+ */
+package com.arjuna.common.internal.util.logging.basic;
+
+import com.arjuna.common.util.exceptions.LogConfigurationException;
+import com.arjuna.common.internal.util.logging.LogFactoryInterface;
+import com.arjuna.common.internal.util.logging.LogInterface;
+
+/**
+ * LogFactoryInterface impl for the built-in logger.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com)
+ */
+public class BasicLogFactory implements LogFactoryInterface
+{
+ /**
+ * Convenience method to return a named logger, without the application
+ * having to care about factories.
+ *
+ * @param name Logical name of the <code>Log</code> instance to be
+ * returned (the meaning of this name is only known to the underlying
+ * logging implementation that is being wrapped)
+ * @throws com.arjuna.common.util.exceptions.LogConfigurationException
+ * if a suitable <code>Log</code>
+ * instance cannot be returned
+ */
+ @Override
+ public LogInterface getLog(String name) throws LogConfigurationException
+ {
+ return new BasicLog(name);
+ }
+}
Modified: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/commonPropertyManager.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/commonPropertyManager.java 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/commonPropertyManager.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -21,17 +21,15 @@
package com.arjuna.common.internal.util.logging;
import com.arjuna.common.internal.util.propertyservice.BeanPopulator;
+import com.arjuna.common.internal.util.logging.basic.BasicLogEnvironmentBean;
/**
* This class is used to control properties values for CLF.
*
- * The properties can originate either from a configuration file (by default common.properties)
+ * The properties can originate either from a configuration file
* or it can be primed by using the class directly from an embedding product (such as
* the JBoss Transaction Service).
*
- * The default file location can be overridden by setting the property
- * "com.arjuna.common.util.logging.propertiesFile"
- *
* @author Malik SAHEB
*/
public class commonPropertyManager
@@ -41,8 +39,8 @@
return BeanPopulator.getSingletonInstance(LoggingEnvironmentBean.class);
}
- public static DefaultLogEnvironmentBean getDefaultLogEnvironmentBean()
+ public static BasicLogEnvironmentBean getBasicLogEnvironmentBean()
{
- return BeanPopulator.getSingletonInstance(DefaultLogEnvironmentBean.class);
+ return BeanPopulator.getSingletonInstance(BasicLogEnvironmentBean.class);
}
}
Modified: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/jakarta/JakartaLogFactory.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/jakarta/JakartaLogFactory.java 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/jakarta/JakartaLogFactory.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -29,12 +29,11 @@
package com.arjuna.common.internal.util.logging.jakarta;
import com.arjuna.common.internal.util.logging.LogFactoryInterface;
-import com.arjuna.common.internal.util.logging.AbstractLogInterface;
import com.arjuna.common.internal.util.logging.LogInterface;
import com.arjuna.common.util.exceptions.LogConfigurationException;
/**
- * JavaDoc
+ * LogFactoryInterface impl for Jakarta Commons Logging (JCL)
*
* @author Thomas Rischbeck <thomas.rischbeck at arjuna.com>
* @version $Revision: 2342 $ $Date: 2006-03-30 14:06:17 +0100 (Thu, 30 Mar 2006) $
@@ -59,7 +58,7 @@
* @exception LogConfigurationException if a suitable <code>Log</code>
* instance cannot be returned
*/
- public AbstractLogInterface getLog(Class clazz) throws LogConfigurationException
+ public LogInterface getLog(Class clazz) throws LogConfigurationException
{
Object oldConfig = null;
try
@@ -90,7 +89,7 @@
* @exception LogConfigurationException if a suitable <code>Log</code>
* instance cannot be returned
*/
- public AbstractLogInterface getLog(String name) throws LogConfigurationException
+ public LogInterface getLog(String name) throws LogConfigurationException
{
Object oldConfig = null;
try
Modified: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/jakarta/Log4JLogger.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/jakarta/Log4JLogger.java 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/jakarta/Log4JLogger.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -44,7 +44,7 @@
import org.apache.log4j.Priority;
import org.apache.log4j.Level;
-import com.arjuna.common.internal.util.logging.LogImpl;
+import com.arjuna.common.internal.util.logging.Logi18nImpl;
/**
* Implementation of {@link Log} that maps directly to a
@@ -75,7 +75,7 @@
/** The fully qualified name of the Log4JLogger class. */
//private static final String FQCN = Log4JLogger.class.getName(); // apache version
- private static final String FQCN = LogImpl.class.getName(); // Red Hat modification
+ private static final String FQCN = Logi18nImpl.class.getName(); // Red Hat modification
/** Log to this logger */
private transient Logger logger = null;
Modified: labs/jbosstm/trunk/common/classes/com/arjuna/common/util/logging/LogFactory.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/util/logging/LogFactory.java 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/util/logging/LogFactory.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -34,107 +34,30 @@
import java.lang.reflect.Constructor;
/**
- * Factory for {@link Logi18n Log} objects.
+ * Factory for {@link Logi18n} and {@link LogNoi18n} objects.
*
- * LogFactory returns different subclasses of logger according to which logging subsystem is chosen. The
- * log system is selected through the property <code>com.arjuna.common.utils.logger</code>.
- * Supported values for this property are:
- * <ul>
- * <li><code><b>jakarta</b></code> Jakarta Commons Logging (JCL). JCL can delegate to various other logging subsystems, such as:
- * <ul>
- * <li>log4j</li>
- * <li>JDK 1.4 logging</li>
- * <li>Windows NT syslog</li>
- * <li>console</li>
- * </ul>
- * </li>
- * </ul>
+ * LogFactory instantiates and returns different implementations of Logi18n and LogNoi18n according to
+ * which logging subsystem is configured.
+ *
+ * The LoggingEnvironmentBean.loggingFactory property supplies factory setup information which is used to
+ * instantiate a LogFactoryInterface implementation, from which a LogInterface implementation is then obtained.
+ * See the environment bean for factory config options and also log level settings.
+ *
+ * The LogInterface impl provides access to the underlying logging system for our logging abstraction layer.
+ * Logi18n and LogNoi18n implementations wrap the LogInterface impl and are passed back to the user code.
+ * Note the assumption that the underlying log system is not i18n aware i.e. message internationalization is done
+ * in the Logi18n impl before messages are passed to the LogInterface.
+ * TODO: this model need revision so we can support i18n aware underlying loggers.
+ *
* Note: Log subsystems are not configured through CLF but instead rely on their own configuration files for
* the setup of eg. debug level, appenders, etc...
*
- * <h4>The Default <code>LogFactory</code> Implementation</h4>
- *
- * <p>The Logging Package APIs include a default <code>LogFactory</code>
- * implementation class (<a href="impl/LogFactoryImpl.html">
- * org.apache.commons.logging.impl.LogFactoryImpl</a>) that is selected if no
- * other implementation class name can be discovered. Its primary purpose is
- * to create (as necessary) and return <a href="Log.html">Log</a> instances
- * in response to calls to the <code>getInstance()</code> method. The default
- * implementation uses the following rules:</p>
- * <ul>
- * <li>At most one <code>Log</code> instance of the same name will be created.
- * Subsequent <code>getInstance()</code> calls to the same
- * <code>LogFactory</code> instance, with the same name or <code>Class</code>
- * parameter, will return the same <code>Log</code> instance.</li>
- * <li>When a new <code>Log</code> instance must be created, the default
- * <code>LogFactory</code> implementation uses the following discovery
- * process is used:
- * <ul>
- * <li>Look for a configuration attribute of this factory named
- * <code>org.apache.commons.logging.Log</code> (for backwards
- * compatibility to pre-1.0 versions of this API, an attribute
- * <code>org.apache.commons.logging.log</code> is also consulted)..</li>
- * <li>Look for a system property named
- * <code>org.apache.commons.logging.Log</code> (for backwards
- * compatibility to pre-1.0 versions of this API, a system property
- * <code>org.apache.commons.logging.log</code> is also consulted).</li>
- * <li>If the Log4J logging system is available in the application
- * class path, use the corresponding wrapper class
- * (<a href="impl/Log4JLogger.html">Log4JLogger</a>).</li>
- * <li>If the application is executing on a JDK 1.4 system, use
- * the corresponding wrapper class
- * (<a href="impl/Jdk14Logger.html">Jdk14Logger</a>).</li>
- * <li>Fall back to the default simple logging wrapper
- * (<a href="impl/SimpleLog.html">SimpleLog</a>).</li>
- * </ul></li>
- * <li>Load the class of the specified name from the thread context class
- * loader (if any), or from the class loader that loaded the
- * <code>LogFactory</code> class otherwise.</li>
- * <li>Instantiate an instance of the selected <code>Log</code>
- * implementation class, passing the specified name as the single
- * argument to its constructor.</li>
- * </ul>
- *
* @author Thomas Rischbeck <thomas.rischbeck at arjuna.com>
* @version $Revision: 2342 $ $Date: 2006-03-30 14:06:17 +0100 (Thu, 30 Mar 2006) $
* @since clf-2.0
*/
public class LogFactory {
- /**
- * this is the name of a system property that can be used to explicitly select a particular logging
- * subsystem.
- *
- * See the class description for supported values.
- */
- @Deprecated
- public static final String LOGGER_PROPERTY = "com.arjuna.common.util.logger";
-
-
- /***************************************************************************
- * Property names to control fine-grained logging
- *
- * TODO: TR: this requires some more thought. currently the values can only be set
- * for the root logger, but some hierarchical scheme would be nice
- * we might also want to explore dynamic proxies to automaticlaly obtain debug
- * output for all methods & constructors, etc ...
- */
- @Deprecated
- public static final String DEBUG_LEVEL = "com.arjuna.common.util.logging.DebugLevel";
- @Deprecated
- public static final String FACILITY_LEVEL = "com.arjuna.common.util.logging.FacilityLevel";
- @Deprecated
- public static final String VISIBILITY_LEVEL = "com.arjuna.common.util.logging.VisibilityLevel";
-
- //private static final String CSF_LOGGER = "csf";
- private static final String JAKARTA_LOGGER = "jakarta";
- private static final String LOG4J = "log4j";
- private static final String JDK14 = "jdk14";
- private static final String SIMPLE = "simple";
- private static final String NOOP = "noop";
- //private static final String AVALON = "avalon";
- private static final String RELEVELER = "log4j_releveler";
-
/**
* Interface that encapsulates the underlying, log-system-specific log factory.
*/
@@ -177,18 +100,13 @@
* @param name Logical name of the <code>Log</code> instance to be
* returned (the meaning of this name is only known to the underlying
* logging implementation that is being wrapped).
+ * @return a LogNoi18n instance
* <p>
*/
public static LogNoi18n getLogNoi18n(String name) {
- LogNoi18n log = null;
setupLogSystem();
- AbstractLogInterface logInterface = m_logFactory.getLog(name);
- if (logInterface instanceof LogInterface) {
- log = new LogNoi18nImpl((LogInterface) logInterface);
- } else {
- throw new RuntimeException("non i18n loggers are not supported for CSF!");
- }
- log.setLevels(m_debugLevel, m_visLevel, m_facLevel);
+ LogInterface logInterface = m_logFactory.getLog(name);
+ LogNoi18n log = new LogNoi18nImpl(logInterface, m_debugLevel, m_visLevel, m_facLevel);
return log;
}
@@ -196,69 +114,16 @@
* Convenience method to return a named logger, without the application
* having to care about factories.
*
- * @param clazz Class for which a log name will be derived
- */
- public static Logi18n getLogi18n(Class clazz) {
- Logi18n log = null;
- setupLogSystem();
- AbstractLogInterface logInterface = m_logFactory.getLog(clazz);
- log = new LogImpl((LogInterface) logInterface);
- log.setLevels(m_debugLevel, m_visLevel, m_facLevel);
- return log;
- }
-
- /**
- * Convenience method to return a named logger, without the application
- * having to care about factories.
- *
* @param name Logical name of the <code>Log</code> instance to be
* returned (the meaning of this name is only known to the underlying
- * logging implementation that is being wrapped).
- * <p>
- * Note that <code>name</code> is also used as the default resource bundle
- * associated with the logger (although an explicit resource bundle is not
- * required for the debugb, warnb, etc methods.
- */
- public static Logi18n getLogi18n(String name) {
- Logi18n log = null;
- setupLogSystem();
- AbstractLogInterface logInterface = m_logFactory.getLog(name);
- log = new LogImpl((LogInterface) logInterface, name);
- log.setLevels(m_debugLevel, m_visLevel, m_facLevel);
- return log;
- }
-
- /**
- * Convenience method to return a named logger, without the application
- * having to care about factories.
- *
- * @param clazz Class for which a log name will be derived
- * @param resBundle resource bundle to use for the logger
- */
- public static Logi18n getLogi18n(Class clazz, String resBundle) {
- Logi18n log = null;
- setupLogSystem();
- AbstractLogInterface logInterface = m_logFactory.getLog(clazz);
- log = new LogImpl((LogInterface) logInterface, resBundle);
- log.setLevels(m_debugLevel, m_visLevel, m_facLevel);
- return log;
- }
-
- /**
- * Convenience method to return a named logger, without the application
- * having to care about factories.
- *
- * @param name Logical name of the <code>Log</code> instance to be
- * returned (the meaning of this name is only known to the underlying
* logging implementation that is being wrapped)
* @param resBundle resource bundle associated with the returned logger.
+ * @return a Logi18n instance
*/
public static Logi18n getLogi18n(String name, String resBundle) {
- Logi18n log = null;
setupLogSystem();
- AbstractLogInterface logInterface = m_logFactory.getLog(name);
- log = new LogImpl((LogInterface) logInterface, resBundle);
- log.setLevels(m_debugLevel, m_visLevel, m_facLevel);
+ LogInterface logInterface = m_logFactory.getLog(name);
+ Logi18n log = new Logi18nImpl(logInterface, resBundle, m_debugLevel, m_visLevel, m_facLevel);
return log;
}
@@ -270,37 +135,28 @@
return;
}
- String debugLevel = "0xffffffff";
- String facLevel = "0xfffffff";
- String visLevel = "0xfffffff";
- String logSystem = NOOP;
+ String debugLevel;
+ String facLevel;
+ String visLevel;
+ String logFactory;
try
{
- try
- {
- // find out which log subsystem to use; by default log4j:
- logSystem = commonPropertyManager.getLoggingEnvironmentBean().getLoggingSystem();
+ // find out which log subsystem to use:
+ logFactory = commonPropertyManager.getLoggingEnvironmentBean().getLoggingFactory();
debugLevel = commonPropertyManager.getLoggingEnvironmentBean().getDebugLevel();
facLevel = commonPropertyManager.getLoggingEnvironmentBean().getFacilityLevel();
visLevel = commonPropertyManager.getLoggingEnvironmentBean().getVisibilityLevel();
- }
- catch (Throwable t)
- {
- // an exception could occur when trying to read system properties when we run in an applet
- // sandbox. therefore, ignore the trowable and just keep with the default settings above.
- }
-
try {
- m_debugLevel = Long.decode(debugLevel).longValue();
+ m_debugLevel = Long.decode(debugLevel);
} catch (NumberFormatException nfe) {
m_debugLevel = 0x0;
}
try {
- m_facLevel = Long.decode(facLevel).longValue();
+ m_facLevel = Long.decode(facLevel);
}
catch (NumberFormatException nfe )
{
@@ -308,40 +164,20 @@
}
try {
- m_visLevel = Long.decode(visLevel).longValue();
+ m_visLevel = Long.decode(visLevel);
}
catch (NumberFormatException nfe )
{
m_debugLevel = 0xfffffff;
}
-
- // ALL THESE ARE SUPPORTED BY JAKARTA COMMONS LOGGING
- if (logSystem.equals(LOG4J)) {
- m_logFactory = loadFactory("com.arjuna.common.internal.util.logging.jakarta.JakartaLogFactory", "com.arjuna.common.internal.util.logging.jakarta.Log4JLogger");
- } else if (logSystem.equals(JDK14)) {
- m_logFactory = loadFactory("com.arjuna.common.internal.util.logging.jakarta.JakartaLogFactory", "org.apache.commons.logging.impl.Jdk14Logger");
- } else if (logSystem.equals(SIMPLE)) {
- m_logFactory = loadFactory("com.arjuna.common.internal.util.logging.jakarta.JakartaLogFactory", "org.apache.commons.logging.impl.SimpleLog");
- } else if (logSystem.equals(NOOP)) {
- m_logFactory = loadFactory("com.arjuna.common.internal.util.logging.jakarta.JakartaLogFactory", "org.apache.commons.logging.impl.NoOpLog");
+
+ int semicolonIndex = logFactory.indexOf(";");
+ if(semicolonIndex == -1) {
+ m_logFactory = loadFactory(logFactory, null);
+ } else {
+ m_logFactory = loadFactory(logFactory.substring(0, semicolonIndex), logFactory.substring(semicolonIndex+1));
}
- // we use a slightly modified wrapper to do log statement level modification
- // for support of JBossAS log level semantics, see JakartaRelevelingLogger javadoc
- else if (logSystem.equals(RELEVELER)) {
- m_logFactory = loadFactory("com.arjuna.common.internal.util.logging.jakarta.JakartaRelevelingLogFactory", "com.arjuna.common.internal.util.logging.jakarta.Log4JLogger");
- }
-
- // USE JAKARTA COMMONS LOGGINGS OWN DISCOVERY MECHANISM
- else if (logSystem.equals(JAKARTA_LOGGER)) {
- m_logFactory = loadFactory("com.arjuna.common.internal.util.logging.jakarta.JakartaLogFactory", null);
- }
-
- // by default, use jakarta logging ...
- else {
- m_logFactory = loadFactory("com.arjuna.common.internal.util.logging.jakarta.JakartaLogFactory", null);
- }
-
} catch (LogConfigurationException e) {
throw new RuntimeException("An unexpected exception occurred while creating the logger factory: " + e.getMessage(), e);
}
@@ -355,7 +191,7 @@
{
try {
Class factoryClass = Thread.currentThread().getContextClassLoader().loadClass(classname);
- LogFactoryInterface logFactoryInterface = null;
+ LogFactoryInterface logFactoryInterface;
if(arg == null) {
logFactoryInterface = (LogFactoryInterface)factoryClass.newInstance();
} else {
Modified: labs/jbosstm/trunk/common/classes/com/arjuna/common/util/logging/LogNoi18n.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/util/logging/LogNoi18n.java 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/util/logging/LogNoi18n.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -102,52 +102,30 @@
boolean isFatalEnabled();
-
-
-
/************************ Log Debug Messages ****************************/
/**
* Log a message with DEBUG Level
*
* @param message the message to log
+ * @deprecated use debug(long dl, long vl, long fl, String message);
*/
- void debug(Object message);
-
- /**
- * Log a message with DEBUG Level
- *
- * @param message the message to log
- */
void debug(String message);
-
/**
* Log a message with INFO Level
*
* @param message the message to log
+ * @deprecated use i18n
*/
- void info(Object message);
-
- /**
- * Log a message with INFO Level
- *
- * @param message the message to log
- */
void info(String message);
/**
* Log a message with WARN Level
*
* @param message the message to log
+ * @deprecated should take a Throwable
*/
- void warn(Object message);
-
- /**
- * Log a message with WARN Level
- *
- * @param message the message to log
- */
void warn(String message);
/**
@@ -155,12 +133,13 @@
*
* @param message the message to log
*/
- void error(Object message);
+ void error(Throwable message);
/**
* Log a message with ERROR Level
*
* @param message the message to log
+ * @deprecated use I18n
*/
void error(String message);
@@ -168,14 +147,8 @@
* Log a message with FATAL Level
*
* @param message the message to log
+ * @deprecated use i18n instead
*/
- void fatal(Object message);
-
- /**
- * Log a message with FATAL Level
- *
- * @param message the message to log
- */
void fatal(String message);
/**
@@ -195,122 +168,12 @@
* to log only if the DEBUG level is allowed and fl is either equals or greater the facility code level assigned to
* the logger Object
* @param message The message to log.
- *
- * @deprecated
*/
- void debug(long dl, long vl, long fl, Object message);
-
-
- /**
- * Log a message with the DEBUG Level and with finer granularity. The debug message
- * is sent to the output only if the specified debug level, visibility level, and facility code
- * match those allowed by the logger.
- * <p>
- * <b>Note:</b> this method does not use i18n. ie, message is directly used for log output.
- *
- * @param dl The debug finer level associated with the log message. That is, the logger object allows
- * to log only if the DEBUG level is allowed and dl is either equals or greater the debug level assigned to
- * the logger Object
- * @param vl The visibility level associated with the log message. That is, the logger object allows
- * to log only if the DEBUG level is allowed and vl is either equals or greater the visibility level assigned to
- * the logger Object
- * @param fl The facility code level associated with the log message. That is, the logger object allows
- * to log only if the DEBUG level is allowed and fl is either equals or greater the facility code level assigned to
- * the logger Object
- * @param message The message to log.
- */
void debug(long dl, long vl, long fl, String message);
/**************************** Debug Granularity Extension ***************************/
/**
- * Set the debug level, the visibility level, and the facility code.
- *
- * @param dl The finer debugging value.
- * See {@link DebugLevel DebugLevel} for possible values.
- * @param vl The visibility level value.
- * See {@link VisibilityLevel VisibilityLevel} for possible values.
- * @param fl The facility code level value.
- * See {@link FacilityCode FacilityCode} for possible values.
- */
- void setLevels (long dl, long vl, long fl);
-
- /**
- * Return the finer debug level.
- *
- * @return The finer debugging level value associated with the logger
- * @see DebugLevel for possible return values.
- */
- long getDebugLevel ();
-
- /**
- * Set the debug level as available in the {@link DebugLevel DebugLevel}.
- *
- * @param level The finer debugging value
- * @see DebugLevel for possible values of <code>level</code>.
- */
- void setDebugLevel (long level);
-
- /**
- * Merge the debug level provided with that currently used by
- * the controller.
- *
- * @param level The finer debugging value
- * @see DebugLevel for possible values of <code>level</code>.
- */
- void mergeDebugLevel (long level);
-
- /**
- * Return the visibility level.
- *
- * @return The visibility level value associated with the Logger
- * @see VisibilityLevel for possible return values.
- */
- long getVisibilityLevel ();
-
- /**
- * Set the visibility level.
- *
- * @param level The visibility level value
- * @see VisibilityLevel for possible values of <code>level</code>.
- */
- void setVisibilityLevel (long level);
-
- /**
- * Merge the visibility level provided with that currently used by the Logger.
- *
- * @param level The visibility level value
- * @see VisibilityLevel for possible values of <code>level</code>.
- */
- void mergeVisibilityLevel (long level);
-
- /**
- * Return the facility code.
- *
- * @return The facility code value associated with the Logger.
- * @see FacilityCode for possible return values.
- */
- long getFacilityCode ();
-
- /**
- * Set the facility code.
- *
- * @param level The facility code value
- * @see FacilityCode for possible values of <code>level</code>.
- */
- void setFacilityCode (long level);
-
-
- /**
- * Merge the debug level provided with that currently used by the Logger.
- *
- * @param level The visibility level value
- * @see FacilityCode for possible values of <code>level</code>.
- */
- void mergeFacilityCode (long level);
-
-
- /**
* Is it allowed to print finer debugging statements?
*
* This method returns true when the following is set:
@@ -321,52 +184,7 @@
* </ul>
*
* @return true if the Logger allows full logging
+ * @deprecated replace with isDebugEnabled
*/
boolean debugAllowed ();
-
-
- /**
- * Is it allowed to print finer debugging statements with a given debug level?
- *
- * This method assumes that:
- * <ul>
- * <li>visibility level = <code>VisibilityLevel.VIS_ALL</code>.</li>
- * <li>facility code = <code>FacilityCode.FAC_ALL</code>.</li>
- * </ul>
- *
- * @return true if the Logger allows logging for the finer debugging value <code>dLevel</code>.
- * i.e., dLevel is either equals or greater than the finer debug level assigned to the Logger.
- * @param dLevel The debug finer level to check for.
- */
- boolean debugAllowed (long dLevel);
-
-
- /**
- * Is it allowed to print debugging statements?
- *
- * This method assumes <pre> FacilityCode.FAC_ALL)</pre>
- * @return true if the logger allows logging for the finer debugging values - dLevel and vLevel
- * @param dLevel The debug finer level. Used to ask if the logger object allows logging for this value.
- * The answer is yes if dLevel is either equals or greater the debug level assigned to the logger
- * @param vLevel The visibility level. Used to ask if the logger object allows logging for this value.
- * The answer is yes if vLevel is either equals or greater the visibility level assigned to the logger
- */
- boolean debugAllowed (long dLevel, long vLevel);
-
-
- /**
- * Is it allowed to print finer debugging statements with a given debug level,
- * visibility level and facility code level?
- *
- * @return true if the Logger allows logging for the finer debugging value <code>dLevel</code>,
- * visibility level <code>vLevel</code> and facility code level <code>fLevel</code>.
- * i.e., dLevel is equal or greater than the finer debug level assigned to the Logger
- * and vLevel is equal or greater than the visiblity level
- * and fLevel is equal or greater then the facility code level.
- * @param dLevel The debug finer level to check for.
- * @param vLevel The debug visibilty level to check for.
- * @param fLevel The facility code level to check for.
- */
- boolean debugAllowed (long dLevel, long vLevel, long fLevel);
-
}
Modified: labs/jbosstm/trunk/common/classes/com/arjuna/common/util/logging/Logi18n.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/util/logging/Logi18n.java 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/util/logging/Logi18n.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -268,93 +268,6 @@
/**************************** Debug Granularity Extension ***************************/
/**
- * Set the debug level, the visibility level, and the facility code.
- *
- * @param dl The finer debugging value.
- * See {@link DebugLevel DebugLevel} for possible values.
- * @param vl The visibility level value.
- * See {@link VisibilityLevel VisibilityLevel} for possible values.
- * @param fl The facility code level value.
- * See {@link FacilityCode FacilityCode} for possible values.
- */
- void setLevels (long dl, long vl, long fl);
-
- /**
- * Return the finer debug level.
- *
- * @return The finer debugging level value associated with the logger
- * @see DebugLevel for possible return values.
- */
- long getDebugLevel ();
-
- /**
- * Set the debug level as available in the {@link DebugLevel DebugLevel}.
- *
- * @param level The finer debugging value
- * @see DebugLevel for possible values of <code>level</code>.
- */
- void setDebugLevel (long level);
-
- /**
- * Merge the debug level provided with that currently used by
- * the controller.
- *
- * @param level The finer debugging value
- * @see DebugLevel for possible values of <code>level</code>.
- */
- void mergeDebugLevel (long level);
-
- /**
- * Return the visibility level.
- *
- * @return The visibility level value associated with the Logger
- * @see VisibilityLevel for possible return values.
- */
- long getVisibilityLevel ();
-
- /**
- * Set the visibility level.
- *
- * @param level The visibility level value
- * @see VisibilityLevel for possible values of <code>level</code>.
- */
- void setVisibilityLevel (long level);
-
- /**
- * Merge the visibility level provided with that currently used by the Logger.
- *
- * @param level The visibility level value
- * @see VisibilityLevel for possible values of <code>level</code>.
- */
- void mergeVisibilityLevel (long level);
-
- /**
- * Return the facility code.
- *
- * @return The facility code value associated with the Logger.
- * @see FacilityCode for possible return values.
- */
- long getFacilityCode ();
-
- /**
- * Set the facility code.
- *
- * @param level The facility code value
- * @see FacilityCode for possible values of <code>level</code>.
- */
- void setFacilityCode (long level);
-
-
- /**
- * Merge the debug level provided with that currently used by the Logger.
- *
- * @param level The visibility level value
- * @see FacilityCode for possible values of <code>level</code>.
- */
- void mergeFacilityCode (long level);
-
-
- /**
* Is it allowed to print finer debugging statements?
*
* This method returns true when the following is set:
@@ -365,40 +278,12 @@
* </ul>
*
* @return true if the Logger allows full logging
+ * @deprecated replace with isDebugEnabled
*/
boolean debugAllowed ();
/**
- * Is it allowed to print finer debugging statements with a given debug level?
- *
- * This method assumes that:
- * <ul>
- * <li>visibility level = <code>VisibilityLevel.VIS_ALL</code>.</li>
- * <li>facility code = <code>FacilityCode.FAC_ALL</code>.</li>
- * </ul>
- *
- * @return true if the Logger allows logging for the finer debugging value <code>dLevel</code>.
- * i.e., dLevel is either equals or greater than the finer debug level assigned to the Logger.
- * @param dLevel The debug finer level to check for.
- */
- boolean debugAllowed (long dLevel);
-
-
- /**
- * Is it allowed to print debugging statements?
- *
- * This method assumes <pre> FacilityCode.FAC_ALL)</pre>
- * @return true if the logger allows logging for the finer debugging values - dLevel and vLevel
- * @param dLevel The debug finer level. Used to ask if the logger object allows logging for this value.
- * The answer is yes if dLevel is either equals or greater the debug level assigned to the logger
- * @param vLevel The visibility level. Used to ask if the logger object allows logging for this value.
- * The answer is yes if vLevel is either equals or greater the visibility level assigned to the logger
- */
- boolean debugAllowed (long dLevel, long vLevel);
-
-
- /**
* Is it allowed to print finer debugging statements with a given debug level,
* visibility level and facility code level?
*
@@ -410,229 +295,14 @@
* @param dLevel The debug finer level to check for.
* @param vLevel The debug visibilty level to check for.
* @param fLevel The facility code level to check for.
+ * @deprecated replace with isDebugEnabled
*/
boolean debugAllowed (long dLevel, long vLevel, long fLevel);
-
-
- /*************** logging and ResourceBundle Name *******************/
-
- /**
- * Set the name of the resource bundle name that the logger will use
- * to retreive national text
- * @param BaseName The default resource bundle name the logger uses to retreive messages
- */
- void setResourceBundleName(String BaseName);
-
-
- /************************ Log Debug Messages ****************************/
-
- /**
- * Log a message with the DEBUG Level
- * @param baseName The name of resource bundle to localize message
- * @param key The resource bundle key to retrieve a localised string
- * @deprecated
- */
- void debugb(String baseName, String key);
-
-
- /**
- * Log a message with the DEBUG Level and with a throwable arguments
- * @param baseName The name of resource bundle to localize message
- * @param key The resource bundle key to retrieve a localised string
- * @param throwable Throwable associated with the log message
- * @deprecated
- */
- void debugb(String baseName, String key, Throwable throwable);
-
- /**
- * Log a message with the DEBUG Level and with arguments
- * @param baseName The name of resource bundle to localize message
- * @param key The resource bundle key to retrieve a localised string
- * @param params parameters passed to the message
- * @deprecated
- */
- void debugb(String baseName, String key, Object[] params);
-
- /**
- * Log a message with the DEBUG Level, with arguments and with a throwable arguments
- * @param baseName The name of resource bundle to localize message
- * @param key The resource bundle key to retrieve a localised string
- * @param params parameters passed to the message
- * @param throwable Throwable associated with the log message
- * @deprecated
- */
- void debugb(String baseName, String key, Object[] params, Throwable throwable);
-
-
-
-
- /************************ Log Info Messages with bundle Name ****************************/
-
- /**
- * Log a message with the INFO Level
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @deprecated
- */
- void infob(String baseName, String key);
-
- /**
- * Log a message with the INFO Level and with a throwable arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param throwable Throwable associated with the log message
- * @deprecated
- */
- void infob(String baseName, String key, Throwable throwable);
-
- /**
- * Log a message with the INFO Level and with arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- * @deprecated
- */
- void infob(String baseName, String key, Object[] params);
-
- /**
- * Log a message with the INFO Level, with arguments and with a throwable arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- * @param throwable Throwable associated with the log message
- * @deprecated
- */
- void infob(String baseName, String key, Object[] params, Throwable throwable);
-
-
- /************************ Log Warn Messages with Bundle Name ****************************/
-
- /**
- * Log a message with the WARN Level
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @deprecated
- */
- void warnb(String baseName, String key);
-
- /**
- * Log a message with the WARN Level and with a throwable arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param throwable Throwable associated with the log message
- * @deprecated
- */
- void warnb(String baseName, String key, Throwable throwable);
-
- /**
- * Log a message with the WARN Level and with arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- * @deprecated
- */
- void warnb(String baseName, String key, Object[] params);
-
- /**
- * Log a message with the WARN Level, with arguments and with a throwable arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- * @param throwable Throwable associated with the log message
- * @deprecated
- */
- void warnb(String baseName, String key, Object[] params, Throwable throwable);
-
-
- /************************ Log Error Messages with Bundle Name ****************************/
-
- /**
- * Log a message with the ERROR Level
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @deprecated
- */
- void errorb(String baseName, String key);
-
- /**
- * Log a message with the ERROR Level and with a throwable arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param throwable Throwable associated with the log message
- * @deprecated
- */
- void errorb(String baseName, String key, Throwable throwable);
-
- /**
- * Log a message with the ERROR Level and with arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- * @deprecated
- */
- void errorb(String baseName, String key, Object[] params);
-
-
- /**
- * Log a message with the ERROR Level, with arguments and with a throwable arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- * @param throwable Throwable associated with the log message
- * @deprecated
- */
- void errorb(String baseName, String key, Object[] params, Throwable throwable);
-
-
-
- /************************ Log Fatal Messages with Bundle Name **************************/
-
- /**
- * Log a message with the FATAL Level
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @deprecated
- */
- void fatalb(String baseName, String key);
-
-
- /**
- * Log a message with the FATAL Level and with a throwable arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param throwable Throwable associated with the log message
- * @deprecated
- */
- void fatalb(String baseName, String key, Throwable throwable);
-
-
- /**
- * Log a message with the FATAL Level and with arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- * @deprecated
- */
- void fatalb(String baseName, String key, Object[] params);
-
-
- /**
- * Log a message with the FATAL Level, with arguments and with a throwable arguments
- * @param baseName The name of resource bundle to localize message
- * @param key resource bundle key for the message to log
- * @param params parameters passed to the message
- * @param throwable Throwable associated with the log message
- * @deprecated
- */
- void fatalb(String baseName, String key, Object[] params, Throwable throwable);
-
-
/**********************************************************************************************************
* Finer-Granularity Debug Methods.
**********************************************************************************************************/
-
/**
* Log a message with the DEBUG Level and with finer granularity.
* The debug message is sent to the output only if the specified debug level, visibility level,
@@ -719,16 +389,12 @@
* The user supplied parameter <code>key</code> is replaced by its localized
* version from the resource bundle.
*
- * @see #setResourceBundleName
- *
* @param key unique key to identify an entry in the resource bundle.
* @return The localised string according to user's locale and available resource bundles. placeholder message
* if the resource bundle or key cannot be found.
- * //@throws MissingResourceException if the key cannot be found in any of the associated resource bundles.
*/
- public String getString(String key); //throws MissingResourceException;
+ public String getString(String key);
-
/**
* Obtain a localized and parameterized message from one of the resource
* bundles associated with this logger.
@@ -742,42 +408,6 @@
* @param params parameters to fill placeholders (e.g., {0}, {1}) in the resource bundle string.
* @return The localised string according to user's locale and available resource bundles. placeholder message
* if the resource bundle or key cannot be found.
- * //@throws MissingResourceException if the key cannot be found in any of the associated resource bundles.
*/
- public String getString(String key, Object[] params); // throws MissingResourceException;
-
- /**
- * Obtain a localized message from one of the resource bundles associated
- * with this logger.
- *
- * The user supplied parameter <code>key</code> is replaced by its localized
- * version from the resource bundle <code>base</code>.
- *
- * @see #setResourceBundleName
- *
- * @param base resource bundle name
- * @param key unique key to identify an entry in the resource bundle.
- * @return The localised string according to user's locale and available resource bundles. placeholder message
- * if the resource bundle or key cannot be found.
- * //@throws MissingResourceException if the key cannot be found in any of the associated resource bundles.
- */
- public String getString(String base, String key); // throws MissingResourceException;
-
- /**
- * Obtain a localized and parameterized message from the given resource bundle.
- *
- * First, the user supplied <code>key</code> is searched in the resource
- * bundle. Next, the resulting pattern is formatted using
- * {@link java.text.MessageFormat#format(String,Object[])} method with the
- * user supplied object array <code>params</code>.
- *
- * @param base resource bundle name
- * @param key unique key to identify an entry in the resource bundle.
- * @param params parameters to fill placeholders (e.g., {0}, {1}) in the resource bundle string.
- * @return The localised string according to user's locale and available resource bundles. placeholder message
- * if the resource bundle or key cannot be found.
- * //@throws MissingResourceException if the key cannot be found in any of the associated resource bundles.
- */
- public String getString(String base, String key, Object[] params); // throws MissingResourceException;
-
+ public String getString(String key, Object[] params);
}
Modified: labs/jbosstm/trunk/common/tests/com/arjuna/common/tests/simple/BeanPopulatorTest.java
===================================================================
--- labs/jbosstm/trunk/common/tests/com/arjuna/common/tests/simple/BeanPopulatorTest.java 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/common/tests/com/arjuna/common/tests/simple/BeanPopulatorTest.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -4,7 +4,7 @@
import static org.junit.Assert.assertTrue;
import com.arjuna.common.internal.util.propertyservice.BeanPopulator;
import com.arjuna.common.internal.util.logging.LoggingEnvironmentBean;
-import com.arjuna.common.internal.util.logging.DefaultLogEnvironmentBean;
+import com.arjuna.common.internal.util.logging.basic.BasicLogEnvironmentBean;
import java.util.Set;
import java.util.HashSet;
@@ -26,8 +26,6 @@
expectedKeys.add("com.arjuna.common.util.logging.language");
expectedKeys.add("com.arjuna.common.util.logging.country");
- expectedKeys.add("com.arjuna.common.util.logging.default");
- expectedKeys.add("com.arjuna.common.util.logger");
expectedKeys.add("com.arjuna.common.util.logging.DebugLevel");
expectedKeys.add("com.arjuna.common.util.logging.FacilityLevel");
expectedKeys.add("com.arjuna.common.util.logging.VisibilityLevel");
@@ -43,7 +41,7 @@
DummyProperties testProperties = new DummyProperties();
- BeanPopulator.configureFromProperties(new DefaultLogEnvironmentBean(), testProperties);
+ BeanPopulator.configureFromProperties(new BasicLogEnvironmentBean(), testProperties);
Set<String> expectedKeys = new HashSet<String>();
Modified: labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/debugextension/DebugExt.java
===================================================================
--- labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/debugextension/DebugExt.java 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/debugextension/DebugExt.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -38,7 +38,10 @@
PrintStream originalStream = System.out;
// TODO: how to configure this on a per-test (not per-JVM) basis?
- commonPropertyManager.getLoggingEnvironmentBean().setLoggingSystem("log4j");
+ commonPropertyManager.getLoggingEnvironmentBean().setLoggingFactory("com.arjuna.common.internal.util.logging.jakarta.JakartaLogFactory;com.arjuna.common.internal.util.logging.jakarta.Log4JLogger");
+ commonPropertyManager.getLoggingEnvironmentBean().setDebugLevel("0x"+Long.toString(DebugLevel.FUNCS_AND_OPS, 16));
+ commonPropertyManager.getLoggingEnvironmentBean().setVisibilityLevel("0x"+Long.toString(VisibilityLevel.VIS_PACKAGE, 16));
+ commonPropertyManager.getLoggingEnvironmentBean().setFacilityLevel("0xffffffff"); // FacilityCode.FAC_ALL - Long.toString does the wrong thing.
System.setOut(bufferedStream);
writeLogMessages();
@@ -50,8 +53,6 @@
{
LogNoi18n myNoi18nLog = LogFactory.getLogNoi18n("DebugExt");
- myNoi18nLog.setLevels(DebugLevel.FUNCS_AND_OPS, VisibilityLevel.VIS_PACKAGE, FacilityCode.FAC_ALL);
-
myNoi18nLog.debug(DebugLevel.FUNCS_AND_OPS, VisibilityLevel.VIS_PACKAGE, FacilityCode.FAC_ALL,
"This debug message is enabled since it matches default Finer Values");
@@ -62,7 +63,7 @@
"This debug message is enabled since it the Logger allows full debugging");
}
- public static void verifyResult(String result) {
+ public static void verifyResult(String result) {
String[] lines = result.split("\r?\n");
assertNotNull(lines);
Modified: labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/i18n/logi18n.java
===================================================================
--- labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/i18n/logi18n.java 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/i18n/logi18n.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -42,7 +42,7 @@
PrintStream originalStream = System.out;
// TODO: how to configure this on a per-test (not per-JVM) basis?
- commonPropertyManager.getLoggingEnvironmentBean().setLoggingSystem("log4j");
+ commonPropertyManager.getLoggingEnvironmentBean().setLoggingFactory("com.arjuna.common.internal.util.logging.jakarta.JakartaLogFactory;com.arjuna.common.internal.util.logging.jakarta.Log4JLogger");
System.setOut(bufferedStream);
writeLogMessages();
Modified: labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/testlevels/TestLevels.java
===================================================================
--- labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/testlevels/TestLevels.java 2009-10-29 14:01:33 UTC (rev 29867)
+++ labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/testlevels/TestLevels.java 2009-10-29 14:15:18 UTC (rev 29868)
@@ -73,7 +73,7 @@
// test the releveling for AS integration:
// TODO: how to configure this on a per-test (not per-JVM) basis?
- commonPropertyManager.getLoggingEnvironmentBean().setLoggingSystem("log4j_releveler");
+ commonPropertyManager.getLoggingEnvironmentBean().setLoggingFactory("com.arjuna.common.internal.util.logging.jakarta.JakartaRelevelingLogFactory;com.arjuna.common.internal.util.logging.jakarta.Log4JLogger");
System.setOut(bufferedStream);
writeLogMessages();
More information about the jboss-svn-commits
mailing list