1
0

Consistent prefixes for diagnostics messages. Reduced length (to make more readable when used in container) by stripping package. Changed LogFactory to use OID for classloader.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@377184 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Burrell Donkin
2006-02-12 14:46:03 +00:00
parent db05d3c483
commit 621dd503a6
2 changed files with 18 additions and 6 deletions

View File

@@ -1263,21 +1263,21 @@ public abstract class LogFactory {
// In order to avoid confusion where multiple instances of JCL are // In order to avoid confusion where multiple instances of JCL are
// being used via different classloaders within the same app, we // being used via different classloaders within the same app, we
// ensure each logged message has a prefix of form // ensure each logged message has a prefix of form
// LogFactory@12345: // [LogFactory --> classloader OID]
Class clazz = LogFactory.class; // Note that this prefix should be kept consistent with that
// in LogFactoryImpl
String classLoaderName; String classLoaderName;
try { try {
ClassLoader classLoader = thisClassLoader; ClassLoader classLoader = thisClassLoader;
if (thisClassLoader == null) { if (thisClassLoader == null) {
classLoaderName = "BOOTLOADER"; classLoaderName = "BOOTLOADER";
} else { } else {
classLoaderName = String.valueOf(System.identityHashCode(classLoader)); classLoaderName = objectId(classLoader);
} }
} catch(SecurityException e) { } catch(SecurityException e) {
classLoaderName = "UNKNOWN"; classLoaderName = "UNKNOWN";
} }
diagnosticPrefix = diagnosticPrefix = "[LogFactory -> " + classLoaderName + "] ";
clazz.getName() + "@" + classLoaderName + ": ";
} }
/** /**

View File

@@ -460,9 +460,21 @@ public class LogFactoryImpl extends LogFactory {
// see the context & impl ids from when this object was instantiated, // see the context & impl ids from when this object was instantiated,
// in order to link the impl id output as this object's prefix back to // in order to link the impl id output as this object's prefix back to
// the context it is intended to manage. // the context it is intended to manage.
// Note that this prefix should be kept consistent with that
// in LogFactory.
Class clazz = this.getClass(); Class clazz = this.getClass();
ClassLoader classLoader = getClassLoader(clazz); ClassLoader classLoader = getClassLoader(clazz);
diagnosticPrefix = clazz.getName() + "@" + classLoader.toString() + ":"; String classLoaderName;
try {
if (classLoader == null) {
classLoaderName = "BOOTLOADER";
} else {
classLoaderName = objectId(classLoader);
}
} catch(SecurityException e) {
classLoaderName = "UNKNOWN";
}
diagnosticPrefix = "[LogFactoryImpl -> " + classLoaderName + "] ";
} }