[LOGGING-132] Jdk14Logger now correctly uses the specified logger name.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/logging/trunk@1448063 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -44,6 +44,9 @@ The <action> type attribute can be add,update,fix,remove.
|
|||||||
</properties>
|
</properties>
|
||||||
<body>
|
<body>
|
||||||
<release version="1.1.2" date="In SVN" description="Bug fixes.">
|
<release version="1.1.2" date="In SVN" description="Bug fixes.">
|
||||||
|
<action type="fix" issue="LOGGING-132">
|
||||||
|
Jdk14Logger now correctly uses the specified logger name.
|
||||||
|
</action>
|
||||||
<action type="update" issue="LOGGING-133">
|
<action type="update" issue="LOGGING-133">
|
||||||
Change scope of Jdk14Logger.log(Level, String, Throwable) to protected, allowing
|
Change scope of Jdk14Logger.log(Level, String, Throwable) to protected, allowing
|
||||||
subclasses to modify the logging output.
|
subclasses to modify the logging output.
|
||||||
|
|||||||
@@ -75,13 +75,13 @@ public class Jdk14Logger implements Log, Serializable {
|
|||||||
// Hack (?) to get the stack trace.
|
// Hack (?) to get the stack trace.
|
||||||
Throwable dummyException = new Throwable();
|
Throwable dummyException = new Throwable();
|
||||||
StackTraceElement locations[] = dummyException.getStackTrace();
|
StackTraceElement locations[] = dummyException.getStackTrace();
|
||||||
// Caller will be the third element
|
// LOGGING-132: use the provided logger name instead of the class name
|
||||||
String cname = "unknown";
|
String cname = name;
|
||||||
String method = "unknown";
|
String method = "unknown";
|
||||||
|
// Caller will be the third element
|
||||||
if( locations != null && locations.length > 2 ) {
|
if( locations != null && locations.length > 2 ) {
|
||||||
StackTraceElement caller=locations[2];
|
StackTraceElement caller = locations[2];
|
||||||
cname=caller.getClassName();
|
method = caller.getMethodName();
|
||||||
method=caller.getMethodName();
|
|
||||||
}
|
}
|
||||||
if( ex == null ) {
|
if( ex == null ) {
|
||||||
logger.logp( level, cname, method, msg );
|
logger.logp( level, cname, method, msg );
|
||||||
|
|||||||
@@ -168,10 +168,10 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
|
|||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
setUpManager
|
setUpManager
|
||||||
("org/apache/commons/logging/jdk14/CustomConfig.properties");
|
("org/apache/commons/logging/jdk14/CustomConfig.properties");
|
||||||
setUpLogger("TestLogger");
|
setUpLogger(this.getClass().getName());
|
||||||
setUpHandlers();
|
setUpHandlers();
|
||||||
setUpFactory();
|
setUpFactory();
|
||||||
setUpLog("TestLogger");
|
setUpLog(this.getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -244,7 +244,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
|
|||||||
public void testPristineLogger() {
|
public void testPristineLogger() {
|
||||||
|
|
||||||
assertNotNull("Logger exists", logger);
|
assertNotNull("Logger exists", logger);
|
||||||
assertEquals("Logger name", "TestLogger", logger.getName());
|
assertEquals("Logger name", this.getClass().getName(), logger.getName());
|
||||||
|
|
||||||
// Assert which logging levels have been enabled
|
// Assert which logging levels have been enabled
|
||||||
assertTrue(logger.isLoggable(Level.SEVERE));
|
assertTrue(logger.isLoggable(Level.SEVERE));
|
||||||
|
|||||||
Reference in New Issue
Block a user