[logback-dev] branch, master, updated. c1945db449459277f2bdd97d9bfb97253cefb4a4
added by portage for gitosis-gentoo
git-noreply at pixie.qos.ch
Mon Nov 30 23:18:56 CET 2009
The branch, master has been updated
via c1945db449459277f2bdd97d9bfb97253cefb4a4 (commit)
from f7121aba34e0faef82ca46ea8e2d7b0dfc9bd593 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=c1945db449459277f2bdd97d9bfb97253cefb4a4
http://github.com/ceki/logback/commit/c1945db449459277f2bdd97d9bfb97253cefb4a4
commit c1945db449459277f2bdd97d9bfb97253cefb4a4
Author: Ceki Gulcu <ceki at qos.ch>
Date: Mon Nov 30 23:16:43 2009 +0100
- Fixed http://jira.qos.ch/browse/LBCLASSIC-102 and added relevant test cases
diff --git a/logback-classic/pom.xml b/logback-classic/pom.xml
index 286d0e6..cbb6bea 100644
--- a/logback-classic/pom.xml
+++ b/logback-classic/pom.xml
@@ -215,8 +215,11 @@
of java code. -->
<Import-Package>
- sun.reflect;resolution:=optional, javax.*;resolution:=optional,
- ch.qos.logback.core.rolling, ch.qos.logback.core.rolling.helper,
+ sun.reflect;resolution:=optional,
+ javax.*;resolution:=optional,
+ org.xml.*;resolution:=optional,
+ ch.qos.logback.core.rolling,
+ ch.qos.logback.core.rolling.helper,
*
</Import-Package>
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/ClassicConstants.java b/logback-classic/src/main/java/ch/qos/logback/classic/ClassicConstants.java
index 03038b5..b2a9fe5 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/ClassicConstants.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/ClassicConstants.java
@@ -14,7 +14,6 @@
package ch.qos.logback.classic;
public class ClassicConstants {
- static public final char LOGGER_SEPARATOR = '.';
static public final String USER_MDC_KEY = "user";
public static final String LOGBACK_CONTEXT_SELECTOR = "logback.ContextSelector";
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java b/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
index cc3cd17..50d6de9 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
@@ -28,6 +28,7 @@ import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.LoggerRemoteView;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.Appender;
+import ch.qos.logback.core.CoreConstants;
import ch.qos.logback.core.spi.AppenderAttachable;
import ch.qos.logback.core.spi.AppenderAttachableImpl;
import ch.qos.logback.core.spi.FilterReply;
@@ -287,12 +288,33 @@ public final class Logger implements org.slf4j.Logger, LocationAwareLogger,
return aai.detachAppender(appender);
}
+ static int getSeparatorIndexOf(String name) {
+ return getSeparatorIndexOf(name, 0);
+ }
+
+ /**
+ * Get the position of the separator character, if any, starting at position
+ * 'fromIndex'.
+ *
+ * @param name
+ * @param fromIndex
+ * @return
+ */
+ static int getSeparatorIndexOf(String name, int fromIndex) {
+ int i = name.indexOf(CoreConstants.DOT, fromIndex);
+ if(i != -1) {
+ return i;
+ } else {
+ return name.indexOf(CoreConstants.DOLLAR, fromIndex);
+ }
+ }
+
/**
* Create a child of this logger by suffix, that is, the part of the name
* extending this logger. For example, if this logger is named "x.y" and the
* lastPart is "z", then the created child logger will be named "x.y.z".
*
- * <p> IMPORTANT: Calls to this method must be within a syncronized block on
+ * <p> IMPORTANT: Calls to this method must be within a synchronized block on
* this logger.
*
* @param lastPart
@@ -302,11 +324,11 @@ public final class Logger implements org.slf4j.Logger, LocationAwareLogger,
* @return
*/
Logger createChildByLastNamePart(final String lastPart) {
- int i_index = lastPart.indexOf(ClassicConstants.LOGGER_SEPARATOR);
+ int i_index = getSeparatorIndexOf(lastPart);
if (i_index != -1) {
throw new IllegalArgumentException("Child name [" + lastPart
+ " passed as parameter, may not include ["
- + ClassicConstants.LOGGER_SEPARATOR + "]");
+ + CoreConstants.DOT + "]");
}
if (childrenList == null) {
@@ -317,7 +339,7 @@ public final class Logger implements org.slf4j.Logger, LocationAwareLogger,
childLogger = new Logger(lastPart, this, this.loggerContext);
} else {
childLogger = new Logger(
- name + ClassicConstants.LOGGER_SEPARATOR + lastPart, this,
+ name + CoreConstants.DOT + lastPart, this,
this.loggerContext);
}
childrenList.add(childLogger);
@@ -353,7 +375,7 @@ public final class Logger implements org.slf4j.Logger, LocationAwareLogger,
static private final int DEFAULT_CHILD_ARRAY_SIZE = 5;
Logger createChildByName(final String childName) {
- int i_index = childName.indexOf(ClassicConstants.LOGGER_SEPARATOR, this.name
+ int i_index = getSeparatorIndexOf(childName, this.name
.length() + 1);
if (i_index != -1) {
throw new IllegalArgumentException("For logger [" + this.name
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java b/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java
index 0c4663a..1fdbaeb 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java
@@ -134,7 +134,7 @@ public class LoggerContext extends ContextBase implements ILoggerFactory,
// in between as well (if they don't already exist)
String childName;
while (true) {
- int h = name.indexOf(ClassicConstants.LOGGER_SEPARATOR, i);
+ int h = Logger.getSeparatorIndexOf(name, i);
if (h == -1) {
childName = name;
} else {
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ClassNameOnlyAbbreviator.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ClassNameOnlyAbbreviator.java
index eed7c7e..7f761e2 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ClassNameOnlyAbbreviator.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ClassNameOnlyAbbreviator.java
@@ -24,6 +24,9 @@ import ch.qos.logback.core.CoreConstants;
public class ClassNameOnlyAbbreviator implements Abbreviator {
public String abbreviate(String fqClassName) {
+ // we ignore the fact that the separator character can also be a dollar
+ // If the inner class is org.good.AClass#Inner, returning
+ // AClass#Inner seems most appropriate
int lastIndex = fqClassName.lastIndexOf(CoreConstants.DOT);
if (lastIndex != -1) {
return fqClassName.substring(lastIndex + 1, fqClassName.length());
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/TargetLengthBasedClassNameAbbreviator.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/TargetLengthBasedClassNameAbbreviator.java
index eac2e65..f4aac29 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/TargetLengthBasedClassNameAbbreviator.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/TargetLengthBasedClassNameAbbreviator.java
@@ -21,7 +21,7 @@ public class TargetLengthBasedClassNameAbbreviator implements Abbreviator {
final int targetLength;
public TargetLengthBasedClassNameAbbreviator(int targetLength) {
- this.targetLength = targetLength;
+ this.targetLength = targetLength;
}
public String abbreviate(String fqClassName) {
@@ -36,9 +36,9 @@ public class TargetLengthBasedClassNameAbbreviator implements Abbreviator {
}
int[] dotIndexesArray = new int[ClassicConstants.MAX_DOTS];
- // a.b.c contains 2 dots but 2+1 parts.
+ // a.b.c contains 2 dots but 2+1 parts.
// see also http://jira.qos.ch/browse/LBCLASSIC-110
- int[] lengthArray = new int[ClassicConstants.MAX_DOTS+1];
+ int[] lengthArray = new int[ClassicConstants.MAX_DOTS + 1];
int dotCount = computeDotIndexes(fqClassName, dotIndexesArray);
@@ -55,8 +55,8 @@ public class TargetLengthBasedClassNameAbbreviator implements Abbreviator {
if (i == 0) {
buf.append(fqClassName.substring(0, lengthArray[i] - 1));
} else {
- buf.append(fqClassName.substring(dotIndexesArray[i - 1], dotIndexesArray[i - 1]
- + lengthArray[i]));
+ buf.append(fqClassName.substring(dotIndexesArray[i - 1],
+ dotIndexesArray[i - 1] + lengthArray[i]));
}
// System.out.println("i=" + i + ", buf=" + buf);
}
@@ -64,11 +64,12 @@ public class TargetLengthBasedClassNameAbbreviator implements Abbreviator {
return buf.toString();
}
-
static int computeDotIndexes(final String className, int[] dotArray) {
int dotCount = 0;
int k = 0;
while (true) {
+ // ignore the $ separator in our computations. This is both convenient
+ // and sensible.
k = className.indexOf(CoreConstants.DOT, k);
if (k != -1 && dotCount < ClassicConstants.MAX_DOTS) {
dotArray[dotCount] = k;
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/HLogger.java b/logback-classic/src/test/java/ch/qos/logback/classic/HLogger.java
index c490af3..b1add24 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/HLogger.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/HLogger.java
@@ -24,6 +24,7 @@ import ch.qos.logback.classic.ClassicConstants;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.Appender;
+import ch.qos.logback.core.CoreConstants;
public class HLogger extends MarkerIgnoringBase {
@@ -237,10 +238,10 @@ public class HLogger extends MarkerIgnoringBase {
* @return
*/
HLogger createChildByLastNamePart(final String lastPart) {
- int i_index = lastPart.indexOf(ClassicConstants.LOGGER_SEPARATOR);
+ int i_index = lastPart.indexOf(CoreConstants.DOT);
if (i_index != -1) {
throw new IllegalArgumentException("Child name [" + lastPart
- + " passed as parameter, may not include [" + ClassicConstants.LOGGER_SEPARATOR
+ + " passed as parameter, may not include [" + CoreConstants.DOT
+ "]");
}
@@ -251,7 +252,7 @@ public class HLogger extends MarkerIgnoringBase {
if (this.isRootLogger()) {
childHLogger = new HLogger(lastPart, this);
} else {
- childHLogger = new HLogger(name + ClassicConstants.LOGGER_SEPARATOR + lastPart,
+ childHLogger = new HLogger(name + CoreConstants.DOT + lastPart,
this);
}
childrenMap.put(lastPart, childHLogger);
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTest.java
index 5507ff9..f6350f9 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTest.java
@@ -134,9 +134,30 @@ public class LoggerTest {
assertFalse(logger.isTraceEnabled());
assertFalse(logger.isEnabledFor(Level.TRACE));
}
+ }
+
+ @Test
+ public void innerClass_I() {
+ root.setLevel(Level.DEBUG);
+ Logger a = lc.getLogger("a");
+ a.setLevel(Level.INFO);
+ Logger a_b = lc.getLogger("a$b");
+ assertEquals(Level.INFO, a_b.getEffectiveLevel());
+ }
+ @Test
+ public void innerClass_II() {
+ root.setLevel(Level.DEBUG);
+ Logger a = lc.getLogger(this.getClass());
+ a.setLevel(Level.INFO);
+ Logger a_b = lc.getLogger(new Inner().getClass());
+ assertEquals(Level.INFO, a_b.getEffectiveLevel());
}
+
+ class Inner {
+ }
+
@Test
public void testEnabled_All() throws Exception {
root.setLevel(Level.ALL);
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/control/ControlLoggerContext.java b/logback-classic/src/test/java/ch/qos/logback/classic/control/ControlLoggerContext.java
index 571cdb2..651af43 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/control/ControlLoggerContext.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/control/ControlLoggerContext.java
@@ -18,6 +18,7 @@ import java.util.Map;
import ch.qos.logback.classic.ClassicConstants;
import ch.qos.logback.classic.Level;
+import ch.qos.logback.core.CoreConstants;
/**
* This logger context quite optimized for logger retrieval.
@@ -80,7 +81,7 @@ public class ControlLoggerContext {
int i = 0;
while (true) {
- i = name.indexOf(ClassicConstants.LOGGER_SEPARATOR, i);
+ i = name.indexOf(CoreConstants.DOT, i);
if (i == -1) {
// System.out.println("FINAL-Creating logger named [" + name + "] with
// parent " + parent.getName());
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/control/ScenarioMaker.java b/logback-classic/src/test/java/ch/qos/logback/classic/control/ScenarioMaker.java
index cf2c734..ead333b 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/control/ScenarioMaker.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/control/ScenarioMaker.java
@@ -17,6 +17,7 @@ import java.util.LinkedList;
import ch.qos.logback.classic.ClassicConstants;
import ch.qos.logback.classic.Level;
+import ch.qos.logback.core.CoreConstants;
public class ScenarioMaker {
@@ -76,7 +77,7 @@ public class ScenarioMaker {
childName = ScenarioRandomUtil.randomId();
count += childName.length();
} else {
- childName = loggerName + ClassicConstants.LOGGER_SEPARATOR
+ childName = loggerName + CoreConstants.DOT
+ ScenarioRandomUtil.randomId();
count += childName.length();
}
diff --git a/logback-core/pom.xml b/logback-core/pom.xml
index 873db19..270ed8d 100644
--- a/logback-core/pom.xml
+++ b/logback-core/pom.xml
@@ -137,6 +137,7 @@
<Export-Package>ch.qos.logback.core.*</Export-Package>
<Import-Package>
javax.*;resolution:=optional,
+ org.xml.*;resolution:=optional,
org.codehaus.janino;resolution:=optional,
*
</Import-Package>
diff --git a/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java b/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java
index 5258d1b..520c5f4 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java
@@ -91,9 +91,12 @@ public class CoreConstants {
* Ceki's machine (Orion)
*/
public static long REFERENCE_BIPS = 9000;
+
+
+
static public final char DOT = '.';
-
static public final char TAB = '\t';
+ static public final char DOLLAR = '$';
static public final String SEE_FNP_NOT_SET = "See also http://logback.qos.ch/codes.html#tbr_fnp_not_set";
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index 9d0d4a2..68eb6b0 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -71,6 +71,12 @@
event instead of its own context name.
</p>
+ <p>When a logger is named after an inner class, the '$' is used as
+ a separator, instead of the usual '.'. This fixes the level
+ inheritence issue described in <a
+ href="http://jira.qos.ch/browse/LBCLASSIC-102">LBCLASSIC-102</a>
+ and as reported by Joern Huxhorn.</p>
+
<hr width="80%" align="center" />
<h3>9th of August 2009 - Release of version 0.9.17</h3>
-----------------------------------------------------------------------
Summary of changes:
logback-classic/pom.xml | 7 +++-
.../ch/qos/logback/classic/ClassicConstants.java | 1 -
.../main/java/ch/qos/logback/classic/Logger.java | 32 ++++++++++++++++---
.../java/ch/qos/logback/classic/LoggerContext.java | 2 +-
.../classic/pattern/ClassNameOnlyAbbreviator.java | 3 ++
.../TargetLengthBasedClassNameAbbreviator.java | 13 ++++----
.../test/java/ch/qos/logback/classic/HLogger.java | 7 ++--
.../java/ch/qos/logback/classic/LoggerTest.java | 21 +++++++++++++
.../classic/control/ControlLoggerContext.java | 3 +-
.../qos/logback/classic/control/ScenarioMaker.java | 3 +-
logback-core/pom.xml | 1 +
.../java/ch/qos/logback/core/CoreConstants.java | 5 ++-
logback-site/src/site/pages/news.html | 6 ++++
13 files changed, 83 insertions(+), 21 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
More information about the logback-dev
mailing list