[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. release_0.9.19-8-gc9f58e8
added by portage for gitosis-gentoo
git-noreply at pixie.qos.ch
Tue Mar 30 14:34:45 CEST 2010
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, master has been updated
via c9f58e8f6a1372a08fef830ac1c3e8faa38c5abf (commit)
from 199e8d6d8218c1bf526c224e867891110ac0ecbb (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=c9f58e8f6a1372a08fef830ac1c3e8faa38c5abf
http://github.com/ceki/logback/commit/c9f58e8f6a1372a08fef830ac1c3e8faa38c5abf
commit c9f58e8f6a1372a08fef830ac1c3e8faa38c5abf
Author: Ceki Gulcu <ceki at qos.ch>
Date: Tue Mar 30 14:33:46 2010 +0200
all tests pass
diff --git a/logback-classic/src/test/input/joran/conditional/conditionalConsoleApp_ELSE.xml b/logback-classic/src/test/input/joran/conditional/conditionalConsoleApp_ELSE.xml
new file mode 100644
index 0000000..426fc24
--- /dev/null
+++ b/logback-classic/src/test/input/joran/conditional/conditionalConsoleApp_ELSE.xml
@@ -0,0 +1,41 @@
+
+<configuration>
+
+ <if condition='property("HOSTNAME").equals("XYZ87")'>
+ <then>
+
+ <appender name="CON" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d %-5level %logger{35} - %msg %n</pattern>
+ </encoder>
+ </appender>
+ <root>
+ <appender-ref ref="CON" />
+ </root>
+
+ </then>
+ <else>
+
+ <appender name="LIST" class="ch.qos.logback.core.read.ListAppender"/>
+ <root>
+ <appender-ref ref="LIST" />
+ </root>
+
+ </else>
+ </if>
+
+ <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <file>${randomOutputDir}/conditional.log</file>
+ <encoder>
+ <pattern>%d %-5level %logger{35} - %msg %n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="ERROR">
+ <appender-ref ref="FILE" />
+ </root>
+
+
+
+
+</configuration>
\ No newline at end of file
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java
index 5b4b8c7..e9d6a07 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java
@@ -110,7 +110,7 @@ public class JaninoEventEvaluatorTest {
String k = "key"+diff;
MDC.put("key"+diff, "value"+diff);
- jee.setExpression("mdc.get(\""+k+"\").contains(\"alue\")");
+ jee.setExpression("((String) mdc.get(\""+k+"\")).contains(\"alue\")");
jee.start();
StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext);
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/joran/PackageTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/joran/PackageTest.java
index 5ece151..8235d72 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/joran/PackageTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/joran/PackageTest.java
@@ -17,8 +17,8 @@ import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
-
@RunWith(Suite.class)
- at SuiteClasses( { JoranConfiguratorTest.class, EvaluatorJoranTest.class})
+ at SuiteClasses( { JoranConfiguratorTest.class, EvaluatorJoranTest.class,
+ ch.qos.logback.classic.joran.conditional.PackageTest.class })
public class PackageTest {
}
\ No newline at end of file
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/joran/conditional/ConditionalTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/joran/conditional/ConditionalTest.java
index 0c1329c..be99ad2 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/joran/conditional/ConditionalTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/joran/conditional/ConditionalTest.java
@@ -14,6 +14,8 @@
package ch.qos.logback.classic.joran.conditional;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.net.InetAddress;
@@ -29,6 +31,8 @@ import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.ConsoleAppender;
import ch.qos.logback.core.FileAppender;
import ch.qos.logback.core.joran.spi.JoranException;
+import ch.qos.logback.core.read.ListAppender;
+import ch.qos.logback.core.status.StatusChecker;
import ch.qos.logback.core.testUtil.RandomUtil;
import ch.qos.logback.core.util.CoreTestConstants;
import ch.qos.logback.core.util.StatusPrinter;
@@ -59,7 +63,7 @@ public class ConditionalTest {
}
@Test
- public void conditionalConsoleApp() throws JoranException, IOException,
+ public void conditionalConsoleApp_THEN() throws JoranException, IOException,
InterruptedException {
String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX
@@ -71,7 +75,33 @@ public class ConditionalTest {
ConsoleAppender consoleAppender = (ConsoleAppender) root.getAppender("CON");
assertNotNull(consoleAppender);
StatusPrinter.printIfErrorsOccured(context);
+ StatusChecker checker = new StatusChecker(context);
+ assertTrue(checker.isErrorFree());
+ }
+
+ @Test
+ public void conditionalConsoleApp_ELSE() throws JoranException, IOException,
+ InterruptedException {
-
+ String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX
+ + "conditional/conditionalConsoleApp_ELSE.xml";
+ configure(configFileAsStr);
+
+ StatusPrinter.print(context);
+
+
+ FileAppender fileAppender = (FileAppender) root.getAppender("FILE");
+ assertNotNull(fileAppender);
+
+ ConsoleAppender consoleAppender = (ConsoleAppender) root.getAppender("CON");
+ assertNull(consoleAppender);
+
+ ListAppender listAppender = (ListAppender) root.getAppender("LIST");
+ assertNotNull(listAppender);
+
+ //StatusPrinter.printIfErrorsOccured(context);
+ StatusChecker checker = new StatusChecker(context);
+ assertTrue(checker.isErrorFree());
}
+
}
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/joran/PackageTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/joran/conditional/PackageTest.java
similarity index 85%
copy from logback-classic/src/test/java/ch/qos/logback/classic/joran/PackageTest.java
copy to logback-classic/src/test/java/ch/qos/logback/classic/joran/conditional/PackageTest.java
index 5ece151..3e1ecce 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/joran/PackageTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/joran/conditional/PackageTest.java
@@ -11,7 +11,7 @@
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
*/
-package ch.qos.logback.classic.joran;
+package ch.qos.logback.classic.joran.conditional;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@@ -19,6 +19,6 @@ import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
- at SuiteClasses( { JoranConfiguratorTest.class, EvaluatorJoranTest.class})
+ at SuiteClasses( { ConditionalTest.class})
public class PackageTest {
}
\ No newline at end of file
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/IncludeAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/IncludeAction.java
index 51aa4df..befbdc3 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/IncludeAction.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/IncludeAction.java
@@ -65,7 +65,8 @@ public class IncludeAction extends Action {
// remove the <included> tag from the beginning and </included> from the end
trimHeadAndTail(recorder);
- ec.getJoranInterpreter().addEventsDynamically(recorder.saxEventList);
+ // offset = 2, because we need to get past this element as well as the end element
+ ec.getJoranInterpreter().addEventsDynamically(recorder.saxEventList, 2);
}
void close(InputStream in) {
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/IfAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/IfAction.java
index 513d350..2c35649 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/IfAction.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/IfAction.java
@@ -73,14 +73,12 @@ public class IfAction extends Action {
listToPlay = elseSaxEventList;
}
- if (interpreter.pattern.peekLast().equals("if")) {
- interpreter.pattern.pop();
- interpreter.play(listToPlay);
- interpreter.pattern.push("if");
- }
+ // insert past this event
+ interpreter.addEventsDynamically(listToPlay, 1);
}
+
public void setThenSaxEventList(List<SaxEvent> thenSaxEventList) {
this.thenSaxEventList = thenSaxEventList;
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/PropertyEvalScriptBuilder.java b/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/PropertyEvalScriptBuilder.java
index e29c414..64f7716 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/PropertyEvalScriptBuilder.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/PropertyEvalScriptBuilder.java
@@ -9,7 +9,6 @@ import org.codehaus.janino.ClassBodyEvaluator;
import org.codehaus.janino.CompileException;
import org.codehaus.janino.Parser.ParseException;
import org.codehaus.janino.Scanner.ScanException;
-import org.junit.Before;
import ch.qos.logback.core.spi.ContextAwareBase;
@@ -24,7 +23,6 @@ public class PropertyEvalScriptBuilder extends ContextAwareBase {
Map<String, String> map = new HashMap<String, String>();
- @Before
public Condition build(String script) throws IllegalAccessException,
CompileException, ParseException, ScanException, InstantiationException,
SecurityException, NoSuchMethodException, IllegalArgumentException,
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java
index 7f383f6..528e4fd 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java
@@ -55,7 +55,7 @@ public class EventPlayer {
}
}
- public void addEventsDynamically(List<SaxEvent> eventList) {
- this.eventList.addAll(currentIndex+2, eventList);
+ public void addEventsDynamically(List<SaxEvent> eventList, int offset) {
+ this.eventList.addAll(currentIndex+offset, eventList);
}
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java
index a19603b..b720312 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java
@@ -72,7 +72,7 @@ public class Interpreter {
final private InterpretationContext interpretationContext;
final private ArrayList<ImplicitAction> implicitActions;
final private CAI_WithLocatorSupport cai;
- public Pattern pattern;
+ private Pattern pattern;
Locator locator;
EventPlayer player;
@@ -102,17 +102,19 @@ public class Interpreter {
actionListStack = new Stack<List>();
player = new EventPlayer(this);
}
-
- public void setInterpretationContextPropertiesMap(Map<String, String> propertiesMap) {
+
+ public void setInterpretationContextPropertiesMap(
+ Map<String, String> propertiesMap) {
interpretationContext.setPropertiesMap(propertiesMap);
}
+
/**
* @deprecated replaced by {@link #getInterpretationContext()}
*/
public InterpretationContext getExecutionContext() {
return getInterpretationContext();
}
-
+
public InterpretationContext getInterpretationContext() {
return interpretationContext;
}
@@ -149,9 +151,9 @@ public class Interpreter {
cai.addError(errMsg);
}
}
-
+
/**
- * This method is used to
+ * This method is used to
*/
private void pushEmptyActionList() {
actionListStack.add(EMPTY_LIST);
@@ -179,10 +181,11 @@ public class Interpreter {
}
private void endElement(String namespaceURI, String localName, String qName) {
- // given that an action list is always pushed for every startElement, we need
+ // given that an action list is always pushed for every startElement, we
+ // need
// to always pop for every endElement
List applicableActionList = (List) actionListStack.pop();
-
+
if (skip != null) {
if (skip.equals(pattern)) {
skip = null;
@@ -248,7 +251,8 @@ public class Interpreter {
// logger.debug("set of applicable patterns: " + applicableActionList);
if (applicableActionList == null) {
- applicableActionList = lookupImplicitAction(pattern, attributes, interpretationContext);
+ applicableActionList = lookupImplicitAction(pattern, attributes,
+ interpretationContext);
}
return applicableActionList;
@@ -328,10 +332,33 @@ public class Interpreter {
player.play(eventList);
}
- public void addEventsDynamically(List<SaxEvent> eventList) {
+ public void addEventsDynamically(List<SaxEvent> eventList, int offset) {
if (player != null) {
- player.addEventsDynamically(eventList);
+ player.addEventsDynamically(eventList, offset);
+ }
+ }
+
+ /**
+ * Pop from the stack if the top most element matches 'name'. Returns whether
+ * the top most element matched.
+ *
+ * @param name
+ * @return whether the top most element matched 'name'
+ */
+ public boolean popIfMatch(String name) {
+ boolean match = pattern.peekLast().equals(name);
+ if (match) {
+ pattern.pop();
}
+ return match;
+ }
+
+ /**
+ * Intended for internal use.
+ * @param name
+ */
+ public void patternPush(String name) {
+ pattern.push(name);
}
}
-----------------------------------------------------------------------
Summary of changes:
...nsoleApp.xml => conditionalConsoleApp_ELSE.xml} | 36 ++++++++++-----
.../classic/boolex/JaninoEventEvaluatorTest.java | 2 +-
.../ch/qos/logback/classic/joran/PackageTest.java | 4 +-
.../classic/joran/conditional/ConditionalTest.java | 34 +++++++++++++-
.../classic/joran/conditional}/PackageTest.java | 8 ++--
.../logback/core/joran/action/IncludeAction.java | 3 +-
.../logback/core/joran/conditional/IfAction.java | 8 +--
.../conditional/PropertyEvalScriptBuilder.java | 2 -
.../ch/qos/logback/core/joran/spi/EventPlayer.java | 4 +-
.../ch/qos/logback/core/joran/spi/Interpreter.java | 49 +++++++++++++++----
10 files changed, 108 insertions(+), 42 deletions(-)
copy logback-classic/src/test/input/joran/conditional/{conditionalConsoleApp.xml => conditionalConsoleApp_ELSE.xml} (71%)
copy {logback-core/src/test/java/ch/qos/logback/core/helpers => logback-classic/src/test/java/ch/qos/logback/classic/joran/conditional}/PackageTest.java (87%)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
More information about the logback-dev
mailing list