[jboss-svn-commits] JBoss Common SVN: r2081 - common-logging-spi/trunk/src/main/java/org/jboss/logging
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Sep 27 05:32:59 EDT 2006
Author: adrian at jboss.org
Date: 2006-09-27 05:32:53 -0400 (Wed, 27 Sep 2006)
New Revision: 2081
Modified:
common-logging-spi/trunk/src/main/java/org/jboss/logging/DynamicLogger.java
common-logging-spi/trunk/src/main/java/org/jboss/logging/Logger.java
common-logging-spi/trunk/src/main/java/org/jboss/logging/LoggerPlugin.java
common-logging-spi/trunk/src/main/java/org/jboss/logging/NullLoggerPlugin.java
Log:
Javadoc fixes and code tidyup to test my Maven setup.
Modified: common-logging-spi/trunk/src/main/java/org/jboss/logging/DynamicLogger.java
===================================================================
--- common-logging-spi/trunk/src/main/java/org/jboss/logging/DynamicLogger.java 2006-09-26 22:54:15 UTC (rev 2080)
+++ common-logging-spi/trunk/src/main/java/org/jboss/logging/DynamicLogger.java 2006-09-27 09:32:53 UTC (rev 2081)
@@ -34,15 +34,28 @@
*/
public class DynamicLogger extends Logger
{
+ /** The serialVersionUID */
private static final long serialVersionUID = -5963699806863917370L;
- /** The available log levels */
+ /** No logging */
public static final int LOG_LEVEL_NONE = 0;
+
+ /** Fatal level logging */
public static final int LOG_LEVEL_FATAL = 1;
+
+ /** Error level logging */
public static final int LOG_LEVEL_ERROR = 2;
+
+ /** Warn level logging */
public static final int LOG_LEVEL_WARN = 3;
+
+ /** Info level logging */
public static final int LOG_LEVEL_INFO = 4;
+
+ /** Debug level logging */
public static final int LOG_LEVEL_DEBUG = 5;
+
+ /** Trace level logging */
public static final int LOG_LEVEL_TRACE = 6;
/** The available log level strings */
@@ -51,23 +64,12 @@
/** The log level to use for the "log" primitive */
private int logLevel = LOG_LEVEL_DEBUG;
-
- /**
- * Protected CTOR
- */
- protected DynamicLogger(final String name)
- {
- super(name);
- }
-
- /////////////////////////////////////////////////////////////////////////
- // Factory Methods //
- /////////////////////////////////////////////////////////////////////////
/**
* Create a DynamicLogger instance given the logger name.
*
- * @param name the logger name
+ * @param name the logger name
+ * @return the dynamic logger
*/
public static DynamicLogger getDynamicLogger(String name)
{
@@ -81,6 +83,7 @@
*
* @param name The logger name
* @param suffix A suffix to append to the classname.
+ * @return the dynamic logger
*/
public static DynamicLogger getDynamicLogger(String name, String suffix)
{
@@ -92,6 +95,7 @@
* calls create(clazz.getName()).
*
* @param clazz the Class whose name will be used as the logger name
+ * @return the dynamic logger
*/
public static DynamicLogger getDynamicLogger(Class clazz)
{
@@ -105,16 +109,23 @@
*
* @param clazz The Class whose name will be used as the logger name.
* @param suffix A suffix to append to the classname.
+ * @return the dynamic logger
*/
public static DynamicLogger getDynamicLogger(Class clazz, String suffix)
{
return new DynamicLogger(clazz.getName() + "." + suffix);
}
+
+ /**
+ * Create a new DynamicLogger.
+ *
+ * @param name the log name
+ */
+ protected DynamicLogger(final String name)
+ {
+ super(name);
+ }
- /////////////////////////////////////////////////////////////////////////
- // Extensions to Logger //
- /////////////////////////////////////////////////////////////////////////
-
/**
* Sets the logLevel for the log() primitive
*
@@ -213,6 +224,7 @@
/**
* Logs a message and a throwable using dynamic log level
+ *
* @param message the message to log
* @param t the throwable to log
*/
@@ -250,5 +262,4 @@
break;
}
}
-
}
Modified: common-logging-spi/trunk/src/main/java/org/jboss/logging/Logger.java
===================================================================
--- common-logging-spi/trunk/src/main/java/org/jboss/logging/Logger.java 2006-09-26 22:54:15 UTC (rev 2080)
+++ common-logging-spi/trunk/src/main/java/org/jboss/logging/Logger.java 2006-09-27 09:32:53 UTC (rev 2081)
@@ -21,6 +21,8 @@
*/
package org.jboss.logging;
+import java.io.IOException;
+import java.io.ObjectInputStream;
import java.io.Serializable;
/**
@@ -59,12 +61,16 @@
{
/** Serialization */
private static final long serialVersionUID = 4232175575988879434L;
+
/** The system property to look for an externalized LoggerPlugin implementation class */
protected static String PLUGIN_CLASS_PROP = "org.jboss.logging.Logger.pluginClass";
+
/** The default LoggerPlugin implementation is log4j */
protected static final String LOG4J_PLUGIN_CLASS_NAME = "org.jboss.logging.log4j.Log4jLoggerPlugin";
+
/** The LoggerPlugin implementation class to use */
protected static Class pluginClass = null;
+
/** The class name of the LoggerPlugin implementation class to use */
protected static String pluginClassName = null;
@@ -76,21 +82,26 @@
/** The logger name. */
private final String name;
+ /** The logger plugin delegate */
protected transient LoggerPlugin loggerDelegate = null;
/** The LoggerPlugin implementation class name in use
+ *
* @return LoggerPlugin implementation class name
*/
public static String getPluginClassName()
{
return Logger.pluginClassName;
}
- /** Set the LoggerPlugin implementation class name in use
+
+ /**
+ * Set the LoggerPlugin implementation class name in use
+ *
* @param pluginClassName the LoggerPlugin implementation class name
*/
public static void setPluginClassName(String pluginClassName)
{
- if( pluginClassName.equals(Logger.pluginClassName) == false )
+ if (pluginClassName.equals(Logger.pluginClassName) == false)
{
Logger.pluginClassName = pluginClassName;
init();
@@ -118,6 +129,11 @@
return name;
}
+ /**
+ * Get the logger plugin delegate
+ *
+ * @return the delegate
+ */
public LoggerPlugin getLoggerPlugin()
{
return this.loggerDelegate;
@@ -136,7 +152,8 @@
/**
* Issue a log msg with a level of TRACE.
- * Invokes log.log(XLevel.TRACE, message);
+ *
+ * @param message the message
*/
public void trace(Object message)
{
@@ -145,7 +162,9 @@
/**
* Issue a log msg and throwable with a level of TRACE.
- * Invokes log.log(XLevel.TRACE, message, t);
+ *
+ * @param message the message
+ * @param t the throwable
*/
public void trace(Object message, Throwable t)
{
@@ -166,7 +185,8 @@
/**
* Issue a log msg with a level of DEBUG.
- * Invokes log.log(Level.DEBUG, message);
+ *
+ * @param message the message
*/
public void debug(Object message)
{
@@ -175,7 +195,9 @@
/**
* Issue a log msg and throwable with a level of DEBUG.
- * Invokes log.log(Level.DEBUG, message, t);
+ *
+ * @param message the message
+ * @param t the throwable
*/
public void debug(Object message, Throwable t)
{
@@ -196,7 +218,8 @@
/**
* Issue a log msg with a level of INFO.
- * Invokes log.log(Level.INFO, message);
+ *
+ * @param message the message
*/
public void info(Object message)
{
@@ -205,7 +228,9 @@
/**
* Issue a log msg and throwable with a level of INFO.
- * Invokes log.log(Level.INFO, message, t);
+ *
+ * @param message the message
+ * @param t the throwable
*/
public void info(Object message, Throwable t)
{
@@ -214,7 +239,8 @@
/**
* Issue a log msg with a level of WARN.
- * Invokes log.log(Level.WARN, message);
+ *
+ * @param message the message
*/
public void warn(Object message)
{
@@ -223,7 +249,9 @@
/**
* Issue a log msg and throwable with a level of WARN.
- * Invokes log.log(Level.WARN, message, t);
+ *
+ * @param message the message
+ * @param t the throwable
*/
public void warn(Object message, Throwable t)
{
@@ -232,7 +260,8 @@
/**
* Issue a log msg with a level of ERROR.
- * Invokes log.log(Level.ERROR, message);
+ *
+ * @param message the message
*/
public void error(Object message)
{
@@ -241,7 +270,9 @@
/**
* Issue a log msg and throwable with a level of ERROR.
- * Invokes log.log(Level.ERROR, message, t);
+ *
+ * @param message the message
+ * @param t the throwable
*/
public void error(Object message, Throwable t)
{
@@ -250,7 +281,8 @@
/**
* Issue a log msg with a level of FATAL.
- * Invokes log.log(Level.FATAL, message);
+ *
+ * @param message the message
*/
public void fatal(Object message)
{
@@ -259,19 +291,23 @@
/**
* Issue a log msg and throwable with a level of FATAL.
- * Invokes log.log(Level.FATAL, message, t);
+ *
+ * @param message the message
+ * @param t the throwable
*/
public void fatal(Object message, Throwable t)
{
loggerDelegate.fatal(message, t);
}
- /////////////////////////////////////////////////////////////////////////
- // Custom Serialization //
- /////////////////////////////////////////////////////////////////////////
-
- private void readObject(java.io.ObjectInputStream stream)
- throws java.io.IOException, ClassNotFoundException
+ /**
+ * Custom serialization to reinitalize the delegate
+ *
+ * @param stream the object stream
+ * @throws IOException for any error
+ * @throws ClassNotFoundException if a class is not found during deserialization
+ */
+ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException
{
// restore non-transient fields (aka name)
stream.defaultReadObject();
@@ -284,15 +320,11 @@
this.loggerDelegate = getDelegatePlugin(name);
}
-
- /////////////////////////////////////////////////////////////////////////
- // Factory Methods //
- /////////////////////////////////////////////////////////////////////////
-
/**
* Create a Logger instance given the logger name.
*
- * @param name the logger name
+ * @param name the logger name
+ * @return the logger
*/
public static Logger getLogger(String name)
{
@@ -304,8 +336,9 @@
*
* <p>This will include a logger seperator between classname and suffix
*
- * @param name The logger name
- * @param suffix A suffix to append to the classname.
+ * @param name the logger name
+ * @param suffix a suffix to append to the classname.
+ * @return the logger
*/
public static Logger getLogger(String name, String suffix)
{
@@ -316,7 +349,8 @@
* Create a Logger instance given the logger class. This simply
* calls create(clazz.getName()).
*
- * @param clazz the Class whose name will be used as the logger name
+ * @param clazz the Class whose name will be used as the logger name
+ * @return the logger
*/
public static Logger getLogger(Class clazz)
{
@@ -328,14 +362,21 @@
*
* <p>This will include a logger seperator between classname and suffix
*
- * @param clazz The Class whose name will be used as the logger name.
- * @param suffix A suffix to append to the classname.
+ * @param clazz the Class whose name will be used as the logger name.
+ * @param suffix a suffix to append to the classname.
+ * @return the logger
*/
public static Logger getLogger(Class clazz, String suffix)
{
return new Logger(clazz.getName() + "." + suffix);
}
+ /**
+ * Get the delegate plugin
+ *
+ * @param name the name of the logger
+ * @return the plugin
+ */
protected static LoggerPlugin getDelegatePlugin(String name)
{
LoggerPlugin plugin = null;
@@ -351,18 +392,19 @@
{
plugin.init(name);
}
- catch(Throwable e)
+ catch (Throwable e)
{
String extraInfo = e.getMessage();
- System.err.println("Failed to initalize plugin: " + plugin +
- (extraInfo != null ? ", cause: " + extraInfo : ""));
+ System.err.println("Failed to initalize plugin: " + plugin
+ + (extraInfo != null ? ", cause: " + extraInfo : ""));
plugin = new NullLoggerPlugin();
}
return plugin;
}
- /** Initialize the LoggerPlugin class to use as the delegate to the
+ /**
+ * Initialize the LoggerPlugin class to use as the delegate to the
* logging system. This first checks to see if a pluginClassName has
* been specified via the {@link #setPluginClassName(String)} method,
* then the PLUGIN_CLASS_PROP system property and finally the
@@ -374,7 +416,7 @@
try
{
// See if there is a PLUGIN_CLASS_PROP specified
- if( pluginClassName == null )
+ if (pluginClassName == null)
{
pluginClassName = System.getProperty(PLUGIN_CLASS_PROP, LOG4J_PLUGIN_CLASS_NAME);
}
Modified: common-logging-spi/trunk/src/main/java/org/jboss/logging/LoggerPlugin.java
===================================================================
--- common-logging-spi/trunk/src/main/java/org/jboss/logging/LoggerPlugin.java 2006-09-26 22:54:15 UTC (rev 2080)
+++ common-logging-spi/trunk/src/main/java/org/jboss/logging/LoggerPlugin.java 2006-09-27 09:32:53 UTC (rev 2081)
@@ -1,24 +1,24 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY 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 along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.logging;
/**
@@ -26,45 +26,133 @@
* log4j and /dev/null. Choice is made in org.jboss.logging.Logger
*
* @see org.jboss.logging.Logger
- * @see org.jboss.logging.Log4jLoggerPlugin
* @see org.jboss.logging.NullLoggerPlugin
*
* @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
* @version $Revision$
- *
- * <p><b>Revisions:</b>
- *
- * <p><b>30 mai 2002 Sacha Labourey:</b>
- * <ul>
- * <li> First implementation </li>
- * </ul>
*/
-
public interface LoggerPlugin
{
- // must be called first
- //
- public void init (String name);
-
- public boolean isTraceEnabled();
- public void trace(Object message);
- public void trace(Object message, Throwable t);
+ /**
+ * Initialise the logger with the given name
+ *
+ * @param name the name
+ */
+ void init(String name);
- public boolean isDebugEnabled();
- public void debug(Object message);
- public void debug(Object message, Throwable t);
+ /**
+ * Check to see if the TRACE level is enabled for this logger.
+ *
+ * @return true if a {@link #trace(Object)} method invocation would pass
+ * the msg to the configured appenders, false otherwise.
+ */
+ boolean isTraceEnabled();
- public boolean isInfoEnabled();
- public void info(Object message);
- public void info(Object message, Throwable t);
+ /**
+ * Issue a log msg with a level of TRACE.
+ *
+ * @param message the message
+ */
+ void trace(Object message);
- public void warn(Object message);
- public void warn(Object message, Throwable t);
+ /**
+ * Issue a log msg and throwable with a level of TRACE.
+ *
+ * @param message the message
+ * @param t the throwable
+ */
+ void trace(Object message, Throwable t);
- public void error(Object message);
- public void error(Object message, Throwable t);
+ /**
+ * Check to see if the DEBUG level is enabled for this logger.
+ *
+ * @deprecated DEBUG is for low volume logging, you don't need this
+ * @return true if a {@link #trace(Object)} method invocation would pass
+ * the msg to the configured appenders, false otherwise.
+ */
+ boolean isDebugEnabled();
- public void fatal(Object message);
- public void fatal(Object message, Throwable t);
-
+ /**
+ * Issue a log msg with a level of DEBUG.
+ *
+ * @param message the message
+ */
+ void debug(Object message);
+
+ /**
+ * Issue a log msg and throwable with a level of DEBUG.
+ *
+ * @param message the message
+ * @param t the throwable
+ */
+ void debug(Object message, Throwable t);
+
+ /**
+ * Check to see if the INFO level is enabled for this logger.
+ *
+ * @deprecated INFO is for low volume information, you don't need this
+ * @return true if a {@link #info(Object)} method invocation would pass
+ * the msg to the configured appenders, false otherwise.
+ */
+ boolean isInfoEnabled();
+
+ /**
+ * Issue a log msg with a level of INFO.
+ *
+ * @param message the message
+ */
+ void info(Object message);
+
+ /**
+ * Issue a log msg and throwable with a level of INFO.
+ *
+ * @param message the message
+ * @param t the throwable
+ */
+ void info(Object message, Throwable t);
+
+ /**
+ * Issue a log msg with a level of WARN.
+ *
+ * @param message the message
+ */
+ void warn(Object message);
+
+ /**
+ * Issue a log msg and throwable with a level of WARN.
+ *
+ * @param message the message
+ * @param t the throwable
+ */
+ void warn(Object message, Throwable t);
+
+ /**
+ * Issue a log msg with a level of ERROR.
+ *
+ * @param message the message
+ */
+ void error(Object message);
+
+ /**
+ * Issue a log msg and throwable with a level of ERROR.
+ *
+ * @param message the message
+ * @param t the throwable
+ */
+ void error(Object message, Throwable t);
+
+ /**
+ * Issue a log msg with a level of FATAL.
+ *
+ * @param message the message
+ */
+ void fatal(Object message);
+
+ /**
+ * Issue a log msg and throwable with a level of FATAL.
+ *
+ * @param message the message
+ * @param t the throwable
+ */
+ void fatal(Object message, Throwable t);
}
Modified: common-logging-spi/trunk/src/main/java/org/jboss/logging/NullLoggerPlugin.java
===================================================================
--- common-logging-spi/trunk/src/main/java/org/jboss/logging/NullLoggerPlugin.java 2006-09-26 22:54:15 UTC (rev 2080)
+++ common-logging-spi/trunk/src/main/java/org/jboss/logging/NullLoggerPlugin.java 2006-09-27 09:32:53 UTC (rev 2081)
@@ -1,24 +1,24 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY 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 along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.logging;
/**
@@ -30,64 +30,86 @@
*
* @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
* @version $Revision$
- *
- * <p><b>Revisions:</b>
- *
- * <p><b>30 mai 2002 Sacha Labourey:</b>
- * <ul>
- * <li> First implementation </li>
- * </ul>
*/
-
public class NullLoggerPlugin implements LoggerPlugin
{
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public NullLoggerPlugin () { }
-
- public void init (String name)
- { /* don't care */ }
-
- // Public --------------------------------------------------------
-
- public boolean isTraceEnabled () { return false; }
- public void trace (Object message) { }
- public void trace (Object message, Throwable t) { }
-
- public boolean isDebugEnabled () { return false; }
- public void debug (Object message) { }
- public void debug (Object message, Throwable t) { }
-
- public boolean isInfoEnabled () { return false; }
- public void info (Object message) { }
- public void info (Object message, Throwable t) { }
-
- public void error (Object message) { }
- public void error (Object message, Throwable t) { }
-
- public void fatal (Object message) { }
- public void fatal (Object message, Throwable t) { }
-
- public void warn (Object message) { }
- public void warn (Object message, Throwable t) { }
-
- // Z implementation ----------------------------------------------
-
- // Y overrides ---------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
+ public void init(String name)
+ {
+ /* don't care */
+ }
+
+ public boolean isTraceEnabled()
+ {
+ return false;
+ }
+
+ public void trace(Object message)
+ {
+ // nothing
+ }
+
+ public void trace(Object message, Throwable t)
+ {
+ // nothing
+ }
+
+ public boolean isDebugEnabled()
+ {
+ return false;
+ }
+
+ public void debug(Object message)
+ {
+ // nothing
+ }
+
+ public void debug(Object message, Throwable t)
+ {
+ // nothing
+ }
+
+ public boolean isInfoEnabled()
+ {
+ return false;
+ }
+
+ public void info(Object message)
+ {
+ // nothing
+ }
+
+ public void info(Object message, Throwable t)
+ {
+ // nothing
+ }
+
+ public void error(Object message)
+ {
+ // nothing
+ }
+
+ public void error(Object message, Throwable t)
+ {
+ // nothing
+ }
+
+ public void fatal(Object message)
+ {
+ // nothing
+ }
+
+ public void fatal(Object message, Throwable t)
+ {
+ // nothing
+ }
+
+ public void warn(Object message)
+ {
+ // nothing
+ }
+
+ public void warn(Object message, Throwable t)
+ {
+ // nothing
+ }
}
More information about the jboss-svn-commits
mailing list