Remove obsolete comments
Move static block
This commit is contained in:
@@ -68,8 +68,7 @@ public abstract class LogFactory {
|
|||||||
// lib and JCL have the necessary permissions even when the untrusted
|
// lib and JCL have the necessary permissions even when the untrusted
|
||||||
// caller does not. That's a pretty hard route to exploit though.
|
// caller does not. That's a pretty hard route to exploit though.
|
||||||
|
|
||||||
// ----------------------------------------------------- Manifest Constants
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name ({@code priority}) of the key in the config file used to
|
* The name ({@code priority}) of the key in the config file used to
|
||||||
* specify the priority of that particular config file. The associated value
|
* specify the priority of that particular config file. The associated value
|
||||||
@@ -203,16 +202,14 @@ public abstract class LogFactory {
|
|||||||
*/
|
*/
|
||||||
private static final int MAX_BROKEN_SERVICES = 3;
|
private static final int MAX_BROKEN_SERVICES = 3;
|
||||||
|
|
||||||
// ----------------------------------------------------------- Constructors
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The previously constructed {@code LogFactory} instances, keyed by
|
* The previously constructed {@code LogFactory} instances, keyed by
|
||||||
* the {@code ClassLoader} with which it was created.
|
* the {@code ClassLoader} with which it was created.
|
||||||
*/
|
*/
|
||||||
protected static Hashtable factories;
|
protected static Hashtable factories;
|
||||||
|
|
||||||
// --------------------------------------------------------- Public Methods
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Previously constructed {@code LogFactory} instance as in the
|
* Previously constructed {@code LogFactory} instance as in the
|
||||||
* {@code factories} map, but for the case where
|
* {@code factories} map, but for the case where
|
||||||
@@ -231,39 +228,6 @@ public abstract class LogFactory {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
protected static volatile LogFactory nullClassLoaderFactory;
|
protected static volatile LogFactory nullClassLoaderFactory;
|
||||||
|
|
||||||
static {
|
|
||||||
// note: it's safe to call methods before initDiagnostics (though
|
|
||||||
// diagnostic output gets discarded).
|
|
||||||
final ClassLoader thisClassLoader = getClassLoader(LogFactory.class);
|
|
||||||
thisClassLoaderRef = new WeakReference<>(thisClassLoader);
|
|
||||||
// In order to avoid confusion where multiple instances of JCL are
|
|
||||||
// being used via different classloaders within the same app, we
|
|
||||||
// ensure each logged message has a prefix of form
|
|
||||||
// [LogFactory from classloader OID]
|
|
||||||
//
|
|
||||||
// Note that this prefix should be kept consistent with that
|
|
||||||
// in LogFactoryImpl. However here we don't need to output info
|
|
||||||
// about the actual *instance* of LogFactory, as all methods that
|
|
||||||
// output diagnostics from this class are static.
|
|
||||||
String classLoaderName;
|
|
||||||
try {
|
|
||||||
if (thisClassLoader == null) {
|
|
||||||
classLoaderName = "BOOTLOADER";
|
|
||||||
} else {
|
|
||||||
classLoaderName = objectId(thisClassLoader);
|
|
||||||
}
|
|
||||||
} catch (final SecurityException e) {
|
|
||||||
classLoaderName = "UNKNOWN";
|
|
||||||
}
|
|
||||||
diagnosticPrefix = "[LogFactory from " + classLoaderName + "] ";
|
|
||||||
DIAGNOSTICS_STREAM = initDiagnostics();
|
|
||||||
logClassLoaderEnvironment(LogFactory.class);
|
|
||||||
factories = createFactoryStore();
|
|
||||||
if (isDiagnosticsEnabled()) {
|
|
||||||
logDiagnostic("BOOTSTRAP COMPLETED");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remember this factory, so later calls to LogFactory.getCachedFactory
|
* Remember this factory, so later calls to LogFactory.getCachedFactory
|
||||||
* can return the previously created object (together with all its
|
* can return the previously created object (together with all its
|
||||||
@@ -567,8 +531,7 @@ public abstract class LogFactory {
|
|||||||
return (LogFactory) factories.get(contextClassLoader);
|
return (LogFactory) factories.get(contextClassLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------- Static Variables
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Safely get access to the classloader for the specified class.
|
* Safely get access to the classloader for the specified class.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -728,8 +691,7 @@ public abstract class LogFactory {
|
|||||||
return directGetContextClassLoader();
|
return directGetContextClassLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------- Static Methods
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls LogFactory.directGetContextClassLoader under the control of an
|
* Calls LogFactory.directGetContextClassLoader under the control of an
|
||||||
* AccessController class. This means that java code running under a
|
* AccessController class. This means that java code running under a
|
||||||
@@ -1142,8 +1104,7 @@ public abstract class LogFactory {
|
|||||||
(PrivilegedAction) () -> System.getProperty(key, def));
|
(PrivilegedAction) () -> System.getProperty(key, def));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------ Protected Methods
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the supplied Throwable is one that needs to be
|
* Checks whether the supplied Throwable is one that needs to be
|
||||||
* re-thrown and ignores all others.
|
* re-thrown and ignores all others.
|
||||||
@@ -1656,9 +1617,18 @@ public abstract class LogFactory {
|
|||||||
* @param name Name of the attribute to remove
|
* @param name Name of the attribute to remove
|
||||||
*/
|
*/
|
||||||
public abstract void removeAttribute(String name);
|
public abstract void removeAttribute(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the configuration attribute with the specified name. Calling
|
||||||
|
* this with a {@code null} value is equivalent to calling
|
||||||
|
* {@code removeAttribute(name)}.
|
||||||
|
*
|
||||||
|
* @param name Name of the attribute to set
|
||||||
|
* @param value Value of the attribute to set, or {@code null}
|
||||||
|
* to remove any setting for this attribute
|
||||||
|
*/
|
||||||
|
public abstract void setAttribute(String name, Object value);
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Static initializer block to perform initialization at class load time.
|
|
||||||
//
|
//
|
||||||
// We can't do this in the class constructor, as there are many
|
// We can't do this in the class constructor, as there are many
|
||||||
// static methods on this class that can be called before any
|
// static methods on this class that can be called before any
|
||||||
@@ -1674,16 +1644,38 @@ public abstract class LogFactory {
|
|||||||
//
|
//
|
||||||
// So the wisest thing to do is just to place this code at the very end
|
// So the wisest thing to do is just to place this code at the very end
|
||||||
// of the class file.
|
// of the class file.
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
static {
|
||||||
* Sets the configuration attribute with the specified name. Calling
|
// note: it's safe to call methods before initDiagnostics (though
|
||||||
* this with a {@code null} value is equivalent to calling
|
// diagnostic output gets discarded).
|
||||||
* {@code removeAttribute(name)}.
|
final ClassLoader thisClassLoader = getClassLoader(LogFactory.class);
|
||||||
*
|
thisClassLoaderRef = new WeakReference<>(thisClassLoader);
|
||||||
* @param name Name of the attribute to set
|
// In order to avoid confusion where multiple instances of JCL are
|
||||||
* @param value Value of the attribute to set, or {@code null}
|
// being used via different classloaders within the same app, we
|
||||||
* to remove any setting for this attribute
|
// ensure each logged message has a prefix of form
|
||||||
*/
|
// [LogFactory from classloader OID]
|
||||||
public abstract void setAttribute(String name, Object value);
|
//
|
||||||
|
// Note that this prefix should be kept consistent with that
|
||||||
|
// in LogFactoryImpl. However here we don't need to output info
|
||||||
|
// about the actual *instance* of LogFactory, as all methods that
|
||||||
|
// output diagnostics from this class are static.
|
||||||
|
String classLoaderName;
|
||||||
|
try {
|
||||||
|
if (thisClassLoader == null) {
|
||||||
|
classLoaderName = "BOOTLOADER";
|
||||||
|
} else {
|
||||||
|
classLoaderName = objectId(thisClassLoader);
|
||||||
|
}
|
||||||
|
} catch (final SecurityException e) {
|
||||||
|
classLoaderName = "UNKNOWN";
|
||||||
|
}
|
||||||
|
diagnosticPrefix = "[LogFactory from " + classLoaderName + "] ";
|
||||||
|
DIAGNOSTICS_STREAM = initDiagnostics();
|
||||||
|
logClassLoaderEnvironment(LogFactory.class);
|
||||||
|
factories = createFactoryStore();
|
||||||
|
if (isDiagnosticsEnabled()) {
|
||||||
|
logDiagnostic("BOOTSTRAP COMPLETED");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,8 +53,7 @@ import org.apache.commons.logging.impl.NoOpLog;
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public class LogSource {
|
public class LogSource {
|
||||||
|
|
||||||
// ------------------------------------------------------- Class Attributes
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs.
|
* Logs.
|
||||||
*/
|
*/
|
||||||
@@ -74,8 +73,7 @@ public class LogSource {
|
|||||||
*/
|
*/
|
||||||
private static final String[] EMPTY_STRING_ARRAY = {};
|
private static final String[] EMPTY_STRING_ARRAY = {};
|
||||||
|
|
||||||
// ----------------------------------------------------- Class Initializers
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
||||||
// Is Log4J Available?
|
// Is Log4J Available?
|
||||||
@@ -132,8 +130,7 @@ public class LogSource {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------ Constructor
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a {@code Log} instance by class.
|
* Gets a {@code Log} instance by class.
|
||||||
*
|
*
|
||||||
@@ -144,8 +141,7 @@ public class LogSource {
|
|||||||
return getInstance(clazz.getName());
|
return getInstance(clazz.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------- Class Methods
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a {@code Log} instance by class name.
|
* Gets a {@code Log} instance by class name.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
|
|||||||
/** Serializable version identifier. */
|
/** Serializable version identifier. */
|
||||||
private static final long serialVersionUID = -8649807923527610591L;
|
private static final long serialVersionUID = -8649807923527610591L;
|
||||||
|
|
||||||
// ----------------------------------------------------- Instance Variables
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This member variable simply ensures that any attempt to initialize
|
* This member variable simply ensures that any attempt to initialize
|
||||||
* this class in a pre-1.4 JVM will result in an ExceptionInInitializerError.
|
* this class in a pre-1.4 JVM will result in an ExceptionInInitializerError.
|
||||||
@@ -70,8 +69,7 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
|
|||||||
/** Class and method found flag. */
|
/** Class and method found flag. */
|
||||||
private boolean classAndMethodFound;
|
private boolean classAndMethodFound;
|
||||||
|
|
||||||
// ----------------------------------------------------------- Constructors
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a named instance of this Logger.
|
* Constructs a named instance of this Logger.
|
||||||
*
|
*
|
||||||
@@ -82,8 +80,7 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
|
|||||||
logger = getLogger();
|
logger = getLogger();
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------- Public Methods
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs a message with {@code java.util.logging.Level.FINE}.
|
* Logs a message with {@code java.util.logging.Level.FINE}.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ public class Jdk14Logger implements Log, Serializable {
|
|||||||
*/
|
*/
|
||||||
protected static final Level dummyLevel = Level.FINE;
|
protected static final Level dummyLevel = Level.FINE;
|
||||||
|
|
||||||
// ----------------------------------------------------------- Constructors
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The underlying Logger implementation we are using.
|
* The underlying Logger implementation we are using.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -53,43 +53,9 @@ public class Log4JLogger implements Log, Serializable {
|
|||||||
|
|
||||||
private static final Priority traceLevel;
|
private static final Priority traceLevel;
|
||||||
|
|
||||||
static {
|
|
||||||
if (!Priority.class.isAssignableFrom(Level.class)) {
|
|
||||||
// nope, this is log4j 1.3, so force an ExceptionInInitializerError
|
|
||||||
throw new InstantiationError("Log4J 1.2 not available");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Releases of log4j1.2 >= 1.2.12 have Priority.TRACE available, earlier
|
|
||||||
// versions do not. If TRACE is not available, then we have to map
|
|
||||||
// calls to Log.trace(...) onto the DEBUG level.
|
|
||||||
|
|
||||||
Priority _traceLevel;
|
|
||||||
try {
|
|
||||||
_traceLevel = (Priority) Level.class.getDeclaredField("TRACE").get(null);
|
|
||||||
} catch (final Exception ex) {
|
|
||||||
// ok, trace not available
|
|
||||||
_traceLevel = Level.DEBUG;
|
|
||||||
}
|
|
||||||
traceLevel = _traceLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Log to this logger */
|
/** Log to this logger */
|
||||||
private transient volatile Logger logger;
|
private transient volatile Logger logger;
|
||||||
|
|
||||||
// ------------------------------------------------------------
|
|
||||||
// Static Initializer.
|
|
||||||
//
|
|
||||||
// Note that this must come after the static variable declarations
|
|
||||||
// otherwise initializer expressions associated with those variables
|
|
||||||
// will override any settings done here.
|
|
||||||
//
|
|
||||||
// Verify that log4j is available, and that it is version 1.2.
|
|
||||||
// If an ExceptionInInitializerError is generated, then LogFactoryImpl
|
|
||||||
// will treat that as meaning that the appropriate underlying logging
|
|
||||||
// library is just not present - if discovery is in progress then
|
|
||||||
// discovery will continue.
|
|
||||||
// ------------------------------------------------------------
|
|
||||||
|
|
||||||
/** Logger name */
|
/** Logger name */
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
@@ -333,4 +299,35 @@ public class Log4JLogger implements Log, Serializable {
|
|||||||
public void warn(final Object message, final Throwable t) {
|
public void warn(final Object message, final Throwable t) {
|
||||||
getLogger().log(FQCN, Level.WARN, message, t);
|
getLogger().log(FQCN, Level.WARN, message, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Note that this must come after the static variable declarations
|
||||||
|
// otherwise initializer expressions associated with those variables
|
||||||
|
// will override any settings done here.
|
||||||
|
//
|
||||||
|
// Verify that log4j is available, and that it is version 1.2.
|
||||||
|
// If an ExceptionInInitializerError is generated, then LogFactoryImpl
|
||||||
|
// will treat that as meaning that the appropriate underlying logging
|
||||||
|
// library is just not present - if discovery is in progress then
|
||||||
|
// discovery will continue.
|
||||||
|
static {
|
||||||
|
if (!Priority.class.isAssignableFrom(Level.class)) {
|
||||||
|
// nope, this is log4j 1.3, so force an ExceptionInInitializerError
|
||||||
|
throw new InstantiationError("Log4J 1.2 not available");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Releases of log4j1.2 >= 1.2.12 have Priority.TRACE available, earlier
|
||||||
|
// versions do not. If TRACE is not available, then we have to map
|
||||||
|
// calls to Log.trace(...) onto the DEBUG level.
|
||||||
|
|
||||||
|
Priority _traceLevel;
|
||||||
|
try {
|
||||||
|
_traceLevel = (Priority) Level.class.getDeclaredField("TRACE").get(null);
|
||||||
|
} catch (final Exception ex) {
|
||||||
|
// ok, trace not available
|
||||||
|
_traceLevel = Level.DEBUG;
|
||||||
|
}
|
||||||
|
traceLevel = _traceLevel;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,16 +80,14 @@ public class LogFactoryImpl extends LogFactory {
|
|||||||
*/
|
*/
|
||||||
private static final String[] EMPTY_STRING_ARRAY = {};
|
private static final String[] EMPTY_STRING_ARRAY = {};
|
||||||
|
|
||||||
// ----------------------------------------------------------- Constructors
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name ({@code org.apache.commons.logging.Log}) of the system
|
* The name ({@code org.apache.commons.logging.Log}) of the system
|
||||||
* property identifying our {@link Log} implementation class.
|
* property identifying our {@link Log} implementation class.
|
||||||
*/
|
*/
|
||||||
public static final String LOG_PROPERTY = "org.apache.commons.logging.Log";
|
public static final String LOG_PROPERTY = "org.apache.commons.logging.Log";
|
||||||
|
|
||||||
// ----------------------------------------------------- Manifest Constants
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The deprecated system property used for backwards compatibility with
|
* The deprecated system property used for backwards compatibility with
|
||||||
* old versions of JCL.
|
* old versions of JCL.
|
||||||
@@ -169,8 +167,7 @@ public class LogFactoryImpl extends LogFactory {
|
|||||||
return LogFactory.getClassLoader(clazz);
|
return LogFactory.getClassLoader(clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------- Instance Variables
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the context ClassLoader.
|
* Gets the context ClassLoader.
|
||||||
* This method is a workaround for a java 1.2 compiler bug.
|
* This method is a workaround for a java 1.2 compiler bug.
|
||||||
@@ -280,8 +277,7 @@ public class LogFactoryImpl extends LogFactory {
|
|||||||
*/
|
*/
|
||||||
protected Class[] logConstructorSignature = { String.class };
|
protected Class[] logConstructorSignature = { String.class };
|
||||||
|
|
||||||
// --------------------------------------------------------- Public Methods
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The one-argument {@code setLogFactory} method of the selected
|
* The one-argument {@code setLogFactory} method of the selected
|
||||||
* {@link org.apache.commons.logging.Log} method, if it exists.
|
* {@link org.apache.commons.logging.Log} method, if it exists.
|
||||||
@@ -492,13 +488,11 @@ public class LogFactoryImpl extends LogFactory {
|
|||||||
return logAdapter;
|
return logAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------
|
// Static Methods
|
||||||
// Static Methods
|
|
||||||
//
|
//
|
||||||
// These methods only defined as workarounds for a java 1.2 bug;
|
// These methods only defined as workarounds for a java 1.2 bug;
|
||||||
// theoretically none of these are needed.
|
// theoretically none of these are needed.
|
||||||
// ------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to create a Log instance for the given category name.
|
* Attempts to create a Log instance for the given category name.
|
||||||
* Follows the discovery process described in the class javadoc.
|
* Follows the discovery process described in the class javadoc.
|
||||||
@@ -664,8 +658,7 @@ public class LogFactoryImpl extends LogFactory {
|
|||||||
return attributes.get(name);
|
return attributes.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------ Protected Methods
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an array containing the names of all currently defined
|
* Return an array containing the names of all currently defined
|
||||||
* configuration attributes. If there are no such attributes, a zero
|
* configuration attributes. If there are no such attributes, a zero
|
||||||
|
|||||||
@@ -40,16 +40,14 @@ public class LogKitLogger implements Log, Serializable {
|
|||||||
/** Serializable version identifier. */
|
/** Serializable version identifier. */
|
||||||
private static final long serialVersionUID = 3768538055836059519L;
|
private static final long serialVersionUID = 3768538055836059519L;
|
||||||
|
|
||||||
// ------------------------------------------------------------- Attributes
|
|
||||||
|
|
||||||
/** Logging goes to this {@code LogKit} logger */
|
/** Logging goes to this {@code LogKit} logger */
|
||||||
protected transient volatile Logger logger;
|
protected transient volatile Logger logger;
|
||||||
|
|
||||||
/** Name of this logger */
|
/** Name of this logger */
|
||||||
protected String name;
|
protected String name;
|
||||||
|
|
||||||
// ------------------------------------------------------------ Constructor
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs {@code LogKitLogger} which wraps the {@code LogKit}
|
* Constructs {@code LogKitLogger} which wraps the {@code LogKit}
|
||||||
* logger with given name.
|
* logger with given name.
|
||||||
@@ -61,8 +59,7 @@ public class LogKitLogger implements Log, Serializable {
|
|||||||
this.logger = getLogger();
|
this.logger = getLogger();
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------- Public Methods
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs a message with {@code org.apache.log.Priority.DEBUG}.
|
* Logs a message with {@code org.apache.log.Priority.DEBUG}.
|
||||||
*
|
*
|
||||||
@@ -76,8 +73,7 @@ public class LogKitLogger implements Log, Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------- Log Implementation
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs a message with {@code org.apache.log.Priority.DEBUG}.
|
* Logs a message with {@code org.apache.log.Priority.DEBUG}.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -74,8 +74,7 @@ public class SimpleLog implements Log, Serializable {
|
|||||||
/** Serializable version identifier. */
|
/** Serializable version identifier. */
|
||||||
private static final long serialVersionUID = 136942970684951178L;
|
private static final long serialVersionUID = 136942970684951178L;
|
||||||
|
|
||||||
// ------------------------------------------------------- Class Attributes
|
|
||||||
|
|
||||||
/** All system properties used by {@code SimpleLog} start with this */
|
/** All system properties used by {@code SimpleLog} start with this */
|
||||||
static protected final String systemPrefix = "org.apache.commons.logging.simplelog.";
|
static protected final String systemPrefix = "org.apache.commons.logging.simplelog.";
|
||||||
|
|
||||||
@@ -111,8 +110,7 @@ public class SimpleLog implements Log, Serializable {
|
|||||||
*/
|
*/
|
||||||
static protected DateFormat dateFormatter;
|
static protected DateFormat dateFormatter;
|
||||||
|
|
||||||
// ---------------------------------------------------- Log Level Constants
|
|
||||||
|
|
||||||
/** "Trace" level logging. */
|
/** "Trace" level logging. */
|
||||||
public static final int LOG_LEVEL_TRACE = 1;
|
public static final int LOG_LEVEL_TRACE = 1;
|
||||||
/** "Debug" level logging. */
|
/** "Debug" level logging. */
|
||||||
@@ -132,8 +130,7 @@ public class SimpleLog implements Log, Serializable {
|
|||||||
/** Enable no logging levels */
|
/** Enable no logging levels */
|
||||||
public static final int LOG_LEVEL_OFF = LOG_LEVEL_FATAL + 1;
|
public static final int LOG_LEVEL_OFF = LOG_LEVEL_FATAL + 1;
|
||||||
|
|
||||||
// ------------------------------------------------------------ Initializer
|
|
||||||
|
|
||||||
// Initialize class attributes.
|
// Initialize class attributes.
|
||||||
// Load properties file, if found.
|
// Load properties file, if found.
|
||||||
// Override with system properties.
|
// Override with system properties.
|
||||||
@@ -247,8 +244,7 @@ public class SimpleLog implements Log, Serializable {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------- Attributes
|
|
||||||
|
|
||||||
private static String getStringProperty(final String name) {
|
private static String getStringProperty(final String name) {
|
||||||
String prop = null;
|
String prop = null;
|
||||||
try {
|
try {
|
||||||
@@ -265,13 +261,11 @@ public class SimpleLog implements Log, Serializable {
|
|||||||
/** The name of this simple log instance */
|
/** The name of this simple log instance */
|
||||||
protected volatile String logName;
|
protected volatile String logName;
|
||||||
|
|
||||||
// ------------------------------------------------------------ Constructor
|
|
||||||
|
|
||||||
/** The current log level */
|
/** The current log level */
|
||||||
protected volatile int currentLogLevel;
|
protected volatile int currentLogLevel;
|
||||||
|
|
||||||
// -------------------------------------------------------- Properties
|
|
||||||
|
|
||||||
/** The short name of this simple log instance */
|
/** The short name of this simple log instance */
|
||||||
private volatile String shortLogName;
|
private volatile String shortLogName;
|
||||||
|
|
||||||
@@ -320,8 +314,7 @@ public class SimpleLog implements Log, Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------- Logging Methods
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs a message with
|
* Logs a message with
|
||||||
* {@code org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_DEBUG}.
|
* {@code org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_DEBUG}.
|
||||||
@@ -378,8 +371,7 @@ public class SimpleLog implements Log, Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------- Log Implementation
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message with {@code org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_FATAL}.
|
* Log a message with {@code org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_FATAL}.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ import junit.framework.TestCase;
|
|||||||
*/
|
*/
|
||||||
public class FirstPriorityConfigTestCase extends TestCase {
|
public class FirstPriorityConfigTestCase extends TestCase {
|
||||||
|
|
||||||
// ------------------------------------------- JUnit Infrastructure Methods
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the tests included in this test suite.
|
* Return the tests included in this test suite.
|
||||||
@@ -100,8 +99,7 @@ public class FirstPriorityConfigTestCase extends TestCase {
|
|||||||
LogFactory.releaseAll();
|
LogFactory.releaseAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------- Test Methods
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify that the config file being used is the one containing
|
* Verify that the config file being used is the one containing
|
||||||
* the desired configId value.
|
* the desired configId value.
|
||||||
|
|||||||
@@ -48,8 +48,7 @@ import junit.framework.TestCase;
|
|||||||
|
|
||||||
public class PriorityConfigTestCase extends TestCase {
|
public class PriorityConfigTestCase extends TestCase {
|
||||||
|
|
||||||
// ------------------------------------------- JUnit Infrastructure Methods
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the tests included in this test suite.
|
* Return the tests included in this test suite.
|
||||||
@@ -118,8 +117,7 @@ public class PriorityConfigTestCase extends TestCase {
|
|||||||
LogFactory.releaseAll();
|
LogFactory.releaseAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------- Test Methods
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify that the config file being used is the one containing
|
* Verify that the config file being used is the one containing
|
||||||
* the desired configId value.
|
* the desired configId value.
|
||||||
|
|||||||
@@ -45,8 +45,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
|
|||||||
|
|
||||||
protected static final String HANDLER_NAME = "org.apache.commons.logging.jdk14.TestHandler";
|
protected static final String HANDLER_NAME = "org.apache.commons.logging.jdk14.TestHandler";
|
||||||
|
|
||||||
// ----------------------------------------------------------- Constructors
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make a class available in the system classloader even when its classfile is
|
* Make a class available in the system classloader even when its classfile is
|
||||||
@@ -84,8 +83,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------- Instance Variables
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given the name of a class that is somewhere in the classpath of the provided
|
* Given the name of a class that is somewhere in the classpath of the provided
|
||||||
@@ -157,8 +155,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
|
|||||||
protected LogManager manager;
|
protected LogManager manager;
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------- JUnit Infrastructure Methods
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>The message levels that should have been logged.</p>
|
* <p>The message levels that should have been logged.</p>
|
||||||
@@ -237,8 +234,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------- Test Methods
|
|
||||||
|
|
||||||
|
|
||||||
// Log the messages with exceptions
|
// Log the messages with exceptions
|
||||||
protected void logExceptionMessages() {
|
protected void logExceptionMessages() {
|
||||||
@@ -311,8 +307,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------- Support Methods
|
|
||||||
|
|
||||||
|
|
||||||
// Set up LogManager instance
|
// Set up LogManager instance
|
||||||
protected void setUpManager(final String config) throws Exception {
|
protected void setUpManager(final String config) throws Exception {
|
||||||
|
|||||||
@@ -36,8 +36,7 @@ public class TestAppender extends AppenderSkeleton {
|
|||||||
// The set of logged events for this appender
|
// The set of logged events for this appender
|
||||||
private final List events;
|
private final List events;
|
||||||
|
|
||||||
// ----------------------------------------------------- Instance Variables
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@@ -47,8 +46,7 @@ public class TestAppender extends AppenderSkeleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------- Appender Methods
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void append(final LoggingEvent event) {
|
protected void append(final LoggingEvent event) {
|
||||||
final StandardTests.LogEvent lev = new StandardTests.LogEvent();
|
final StandardTests.LogEvent lev = new StandardTests.LogEvent();
|
||||||
|
|||||||
@@ -39,8 +39,7 @@ import junit.framework.Test;
|
|||||||
public class StandardTestCase extends AbstractLogTest {
|
public class StandardTestCase extends AbstractLogTest {
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------- Instance Variables
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the tests included in this test suite.
|
* Return the tests included in this test suite.
|
||||||
@@ -65,8 +64,7 @@ public class StandardTestCase extends AbstractLogTest {
|
|||||||
protected LogFactory factory;
|
protected LogFactory factory;
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------- JUnit Infrastructure Methods
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>The {@link Log} implementation we have selected.</p>
|
* <p>The {@link Log} implementation we have selected.</p>
|
||||||
@@ -101,8 +99,7 @@ public class StandardTestCase extends AbstractLogTest {
|
|||||||
return new LogKitLogger(this.getClass().getName());
|
return new LogKitLogger(this.getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------- Test Methods
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up instance variables required by this test case.
|
* Sets up instance variables required by this test case.
|
||||||
*/
|
*/
|
||||||
@@ -147,8 +144,7 @@ public class StandardTestCase extends AbstractLogTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------- Support Methods
|
|
||||||
|
|
||||||
// Test Serializability of standard instance
|
// Test Serializability of standard instance
|
||||||
public void testSerializable() throws Exception {
|
public void testSerializable() throws Exception {
|
||||||
checkStandard();
|
checkStandard();
|
||||||
|
|||||||
@@ -83,8 +83,7 @@ public class NoOpLogTestCase extends AbstractLogTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------- Support Methods
|
|
||||||
|
|
||||||
// Test Serializability of standard instance
|
// Test Serializability of standard instance
|
||||||
public void testSerializable() throws Exception {
|
public void testSerializable() throws Exception {
|
||||||
Log log = LogFactory.getLog(this.getClass().getName());
|
Log log = LogFactory.getLog(this.getClass().getName());
|
||||||
|
|||||||
@@ -32,8 +32,7 @@ import junit.framework.Test;
|
|||||||
*/
|
*/
|
||||||
public class DateTimeCustomConfigTestCase extends CustomConfigTestCase {
|
public class DateTimeCustomConfigTestCase extends CustomConfigTestCase {
|
||||||
|
|
||||||
// ----------------------------------------------------------- Constructors
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the tests included in this test suite.
|
* Return the tests included in this test suite.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -79,8 +78,7 @@ public class DateTimeCustomConfigTestCase extends CustomConfigTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------- Methods
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up system properties required by this unit test. Here, we
|
* Sets up system properties required by this unit test. Here, we
|
||||||
* set up the props defined in the parent class setProperties method,
|
* set up the props defined in the parent class setProperties method,
|
||||||
|
|||||||
@@ -33,8 +33,7 @@ import org.apache.commons.logging.impl.SimpleLog;
|
|||||||
public class DecoratedSimpleLog extends SimpleLog {
|
public class DecoratedSimpleLog extends SimpleLog {
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------ Constructor
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated serial version ID.
|
* Generated serial version ID.
|
||||||
@@ -45,8 +44,7 @@ public class DecoratedSimpleLog extends SimpleLog {
|
|||||||
protected ArrayList cache = new ArrayList();
|
protected ArrayList cache = new ArrayList();
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------- Properties
|
|
||||||
|
|
||||||
public DecoratedSimpleLog(final String name) {
|
public DecoratedSimpleLog(final String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
@@ -74,16 +72,14 @@ public class DecoratedSimpleLog extends SimpleLog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------- Protected Methods
|
|
||||||
|
|
||||||
|
|
||||||
public String getLogName() {
|
public String getLogName() {
|
||||||
return logName;
|
return logName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------- Public Methods
|
|
||||||
|
|
||||||
|
|
||||||
public boolean getShowDateTime() {
|
public boolean getShowDateTime() {
|
||||||
return showDateTime;
|
return showDateTime;
|
||||||
|
|||||||
@@ -42,8 +42,7 @@ public class TcclDisabledTestCase extends TestCase {
|
|||||||
public static final String MY_LOG_IMPL =
|
public static final String MY_LOG_IMPL =
|
||||||
MY_LOG_PKG + ".MyLog";
|
MY_LOG_PKG + ".MyLog";
|
||||||
|
|
||||||
// ------------------------------------------- JUnit Infrastructure Methods
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the tests included in this test suite.
|
* Return the tests included in this test suite.
|
||||||
*/
|
*/
|
||||||
@@ -104,8 +103,7 @@ public class TcclDisabledTestCase extends TestCase {
|
|||||||
LogFactory.releaseAll();
|
LogFactory.releaseAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------- Test Methods
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify that MyLog is only loadable via the tccl.
|
* Verify that MyLog is only loadable via the tccl.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -42,8 +42,7 @@ public class TcclEnabledTestCase extends TestCase {
|
|||||||
public static final String MY_LOG_IMPL =
|
public static final String MY_LOG_IMPL =
|
||||||
MY_LOG_PKG + ".MyLog";
|
MY_LOG_PKG + ".MyLog";
|
||||||
|
|
||||||
// ------------------------------------------- JUnit Infrastructure Methods
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the tests included in this test suite.
|
* Return the tests included in this test suite.
|
||||||
*/
|
*/
|
||||||
@@ -104,8 +103,7 @@ public class TcclEnabledTestCase extends TestCase {
|
|||||||
LogFactory.releaseAll();
|
LogFactory.releaseAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------- Test Methods
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify that MyLogFactoryImpl is only loadable via the tccl.
|
* Verify that MyLogFactoryImpl is only loadable via the tccl.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ public class TcclDisabledTestCase extends TestCase {
|
|||||||
public static final String MY_LOG_FACTORY_IMPL =
|
public static final String MY_LOG_FACTORY_IMPL =
|
||||||
MY_LOG_FACTORY_PKG + ".MyLogFactoryImpl";
|
MY_LOG_FACTORY_PKG + ".MyLogFactoryImpl";
|
||||||
|
|
||||||
// ------------------------------------------- JUnit Infrastructure Methods
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the tests included in this test suite.
|
* Return the tests included in this test suite.
|
||||||
@@ -106,8 +105,7 @@ public class TcclDisabledTestCase extends TestCase {
|
|||||||
LogFactory.releaseAll();
|
LogFactory.releaseAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------- Test Methods
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify that MyLogFactoryImpl is only loadable via the tccl.
|
* Verify that MyLogFactoryImpl is only loadable via the tccl.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -35,8 +35,7 @@ import junit.framework.TestCase;
|
|||||||
|
|
||||||
public class TcclEnabledTestCase extends TestCase {
|
public class TcclEnabledTestCase extends TestCase {
|
||||||
|
|
||||||
// ------------------------------------------- JUnit Infrastructure Methods
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the tests included in this test suite.
|
* Return the tests included in this test suite.
|
||||||
@@ -100,8 +99,7 @@ public class TcclEnabledTestCase extends TestCase {
|
|||||||
LogFactory.releaseAll();
|
LogFactory.releaseAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------- Test Methods
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify that MyLogFactoryImpl is only loadable via the tccl.
|
* Verify that MyLogFactoryImpl is only loadable via the tccl.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user