logback-dev
Threads by month
- ----- 2025 -----
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
October 2006
- 6 participants
- 258 discussions
Author: ceki
Date: Thu Oct 19 15:45:50 2006
New Revision: 715
Added:
logback/trunk/logback-core/src/test/input/joran/fruit1.xml
logback/trunk/logback-core/src/test/input/joran/fruit2.xml
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/Fruit.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitAction.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitConfigurationTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitConfigurator.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitContext.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitFactory.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitFactoryAction.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitShell.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitShellAction.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/PackageTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/SimpleConfigurator.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/WeightytFruit.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/PackageTest.java
- copied, changed from r714, /logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/AllTest.java
Removed:
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/FruitConfigAction.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/AllTest.java
Modified:
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedSimplePropertyIA.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Pattern.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SimpleRuleStore.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/PropertySetter.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/AllTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PatternTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/SimpleStoreTest.java
Log:
- Added suffix pattern matching to SimpleRuleStore. We can now do pattern matching
for a/*.
- Tested Joran's newly introduced reconfigure capability.
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java Thu Oct 19 15:45:50 2006
@@ -30,7 +30,7 @@
public abstract class GenericConfigurator extends ContextAwareBase {
- Interpreter interpreter;
+ protected Interpreter interpreter;
final public void doConfigure(URL url) throws JoranException {
try {
@@ -98,7 +98,7 @@
player.play(recorder.saxEventList);
}
- final public void doConfigure(final List<SaxEvent> eventList)
+ public void doConfigure(final List<SaxEvent> eventList)
throws JoranException {
buildInterpreter();
EventPlayer player = new EventPlayer(interpreter);
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedSimplePropertyIA.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedSimplePropertyIA.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedSimplePropertyIA.java Thu Oct 19 15:45:50 2006
@@ -60,7 +60,7 @@
ImplicitActionData ad = new ImplicitActionData(parentBean, containmentType);
ad.propertyName = nestedElementTagName;
actionDataStack.push(ad);
-
+ // System.out.println("NestedSimplePropertyIA deemed applicable for " +pattern);
return true;
default:
addError("PropertySetter.canContainComponent returned " + containmentType);
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Pattern.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Pattern.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Pattern.java Thu Oct 19 15:45:50 2006
@@ -98,7 +98,7 @@
* with the pattern p passed as parameter. By "tail" components we mean the
* components at the end of the pattern.
*/
- public int tailMatch(Pattern p) {
+ public int getTailMatchLength(Pattern p) {
if (p == null) {
return 0;
}
@@ -129,6 +129,43 @@
return match;
}
+ /**
+ * Returns the number of "prefix" components that this pattern has in common
+ * with the pattern p passed as parameter. By "prefix" components we mean the
+ * components at the beginning of the pattern.
+ */
+ public int getPrefixMatchLength(Pattern p) {
+ if (p == null) {
+ return 0;
+ }
+
+ int lSize = this.components.size();
+ int rSize = p.components.size();
+
+ // no match possible for empty sets
+ if ((lSize == 0) || (rSize == 0)) {
+ return 0;
+ }
+
+ int minLen = (lSize <= rSize) ? lSize : rSize;
+ int match = 0;
+
+ for (int i = 0; i < minLen; i++) {
+ String l = (String) this.components.get(i);
+ String r = (String) p.components.get(i);
+
+ if (l.equals(r) || "*".equals(l) || "*".equals(r)) {
+ match++;
+ } else {
+ break;
+ }
+ }
+
+ return match;
+ }
+
+
+
@Override
public boolean equals(Object o) {
//System.out.println("in equals:" +this+ " vs. " + o);
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SimpleRuleStore.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SimpleRuleStore.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SimpleRuleStore.java Thu Oct 19 15:45:50 2006
@@ -12,7 +12,6 @@
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import ch.qos.logback.core.Context;
@@ -67,38 +66,77 @@
}
}
- public List matchActions(Pattern pattern) {
+ // exact match has highest priority
+ // if no exact match, check for tail match, i.e matches of type */x/y
+ // tail match for */x/y has higher priority than match for */x
+ // if no tail match, check for prefix match, i.e. matches for x/*
+ // match for x/y/* has higher priority than matches for x/*
+
+ public List matchActions(Pattern currentPattern) {
//System.out.println("pattern to search for:" + pattern + ", hashcode: " + pattern.hashCode());
//System.out.println("rules:" + rules);
- ArrayList a4p = (ArrayList) rules.get(pattern);
+ List actionList;
- if (a4p != null) {
- return a4p;
+ if ((actionList = rules.get(currentPattern)) != null) {
+ return actionList;
+ } else if ( (actionList = tailMatch(currentPattern)) != null){
+ return actionList;
+ } else if ((actionList = prefixMatch(currentPattern)) != null) {
+ return actionList;
} else {
- Iterator patternsIterator = rules.keySet().iterator();
- int max = 0;
- Pattern longestMatch = null;
-
- while (patternsIterator.hasNext()) {
- Pattern p = (Pattern) patternsIterator.next();
-
- if ((p.size() > 1) && p.get(0).equals("*")) {
- int r = pattern.tailMatch(p);
-
- //System.out.println("tailMatch " +r);
- if (r > max) {
- //System.out.println("New longest match "+p);
- max = r;
- longestMatch = p;
- }
+ return null;
+ }
+ }
+
+ List tailMatch(Pattern currentPattern) {
+ int max = 0;
+ Pattern longestMatchingPattern = null;
+
+ for (Pattern p: rules.keySet()) {
+
+ if ((p.size() > 1) && p.get(0).equals("*")) {
+ int r = currentPattern.getTailMatchLength(p);
+
+ //System.out.println("tailMatch " +r);
+ if (r > max) {
+ //System.out.println("New longest tailMatch "+p);
+ max = r;
+ longestMatchingPattern = p;
}
}
+ }
- if (longestMatch != null) {
- return (ArrayList) rules.get(longestMatch);
- } else {
- return null;
+ if (longestMatchingPattern != null) {
+ return rules.get(longestMatchingPattern);
+ } else {
+ return null;
+ }
+ }
+
+ List prefixMatch(Pattern currentPattern) {
+ int max = 0;
+ Pattern longestMatchingPattern = null;
+
+ for (Pattern p: rules.keySet()) {
+ String last = p.peekLast();
+ if("*".equals(last)) {
+ int r = currentPattern.getPrefixMatchLength(p);
+
+ //System.out.println("prefixMatch " +r);
+ if (r > max) {
+ //System.out.println("New longest prefixMatch "+p);
+ max = r;
+ longestMatchingPattern = p;
+ }
}
}
+
+ if (longestMatchingPattern != null) {
+ //System.out.println("prefixMatch will return" +rules.get(longestMatchingPattern));
+ return rules.get(longestMatchingPattern);
+ } else {
+ return null;
+ }
}
+
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/PropertySetter.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/PropertySetter.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/PropertySetter.java Thu Oct 19 15:45:50 2006
@@ -17,7 +17,6 @@
// Contributors: Georg Lundesgaard
package ch.qos.logback.core.util;
-
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
@@ -31,46 +30,46 @@
import ch.qos.logback.core.Appender;
import ch.qos.logback.core.spi.ContextAwareBase;
-
-
/**
- * General purpose Object property setter. Clients repeatedly invokes
- * {@link #setProperty setProperty(name,value)} in order to invoke setters
- * on the Object specified in the constructor. This class relies on the
- * JavaBeans {@link Introspector} to analyze the given Object Class using
- * reflection.
+ * General purpose Object property setter. Clients repeatedly invokes
+ * {@link #setProperty setProperty(name,value)} in order to invoke setters on
+ * the Object specified in the constructor. This class relies on the JavaBeans
+ * {@link Introspector} to analyze the given Object Class using reflection.
*
- * <p>Usage:
- <pre>
- PropertySetter ps = new PropertySetter(anObject);
- ps.set("name", "Joe");
- ps.set("age", "32");
- ps.set("isMale", "true");
- </pre>
-
- * will cause the invocations anObject.setName("Joe"), anObject.setAge(32),
- * and setMale(true) if such methods exist with those signatures.
- * Otherwise an {@link IntrospectionException} are thrown.
-
- @author Anders Kristensen
- @author Ceki Gulcu
+ * <p>
+ * Usage:
+ *
+ * <pre>
+ * PropertySetter ps = new PropertySetter(anObject);
+ * ps.set("name", "Joe");
+ * ps.set("age", "32");
+ * ps.set("isMale", "true");
+ * </pre>
+ *
+ * will cause the invocations anObject.setName("Joe"), anObject.setAge(32), and
+ * setMale(true) if such methods exist with those signatures. Otherwise an
+ * {@link IntrospectionException} are thrown.
+ *
+ * @author Anders Kristensen
+ * @author Ceki Gulcu
*/
public class PropertySetter extends ContextAwareBase {
public static final int NOT_FOUND = 0;
public static final int AS_COMPONENT = 1;
public static final int AS_PROPERTY = 2;
public static final int AS_COLLECTION = 3;
-
+
protected Object obj;
protected Class objClass;
protected PropertyDescriptor[] propertyDescriptors;
protected MethodDescriptor[] methodDescriptors;
/**
- Create a new PropertySetter for the specified Object. This is done
- in preparation for invoking {@link #setProperty} one or more times.
-
- @param obj the object for which to set properties
+ * Create a new PropertySetter for the specified Object. This is done in
+ * preparation for invoking {@link #setProperty} one or more times.
+ *
+ * @param obj
+ * the object for which to set properties
*/
public PropertySetter(Object obj) {
this.obj = obj;
@@ -78,8 +77,8 @@
}
/**
- Uses JavaBeans {@link Introspector} to computer setters of object to be
- configured.
+ * Uses JavaBeans {@link Introspector} to computer setters of object to be
+ * configured.
*/
protected void introspect() {
try {
@@ -87,15 +86,14 @@
propertyDescriptors = bi.getPropertyDescriptors();
methodDescriptors = bi.getMethodDescriptors();
} catch (IntrospectionException ex) {
- addError(
- "Failed to introspect " + obj + ": " + ex.getMessage());
+ addError("Failed to introspect " + obj + ": " + ex.getMessage());
propertyDescriptors = new PropertyDescriptor[0];
methodDescriptors = new MethodDescriptor[0];
}
}
/**
- * Set the properties for the object that match the <code>prefix</code>
+ * Set the properties for the object that match the <code>prefix</code>
* passed as parameter.
*/
public void setProperties(Properties properties, String prefix) {
@@ -108,13 +106,13 @@
if (key.startsWith(prefix)) {
// ignore key if it contains dots after the prefix
if (key.indexOf('.', len + 1) > 0) {
- //System.err.println("----------Ignoring---["+key
- // +"], prefix=["+prefix+"].");
+ // System.err.println("----------Ignoring---["+key
+ // +"], prefix=["+prefix+"].");
continue;
}
String value = OptionHelper.findAndSubst(key, properties);
-
+
key = key.substring(len);
if ("layout".equals(key) && obj instanceof Appender) {
@@ -127,19 +125,22 @@
}
/**
- Set a property on this PropertySetter's Object. If successful, this
- method will invoke a setter method on the underlying Object. The
- setter is the one for the specified property name and the value is
- determined partly from the setter argument type and partly from the
- value specified in the call to this method.
-
- <p>If the setter expects a String no conversion is necessary.
- If it expects an int, then an attempt is made to convert 'value'
- to an int using new Integer(value). If the setter expects a boolean,
- the conversion is by new Boolean(value).
-
- @param name name of the property
- @param value String value of the property
+ * Set a property on this PropertySetter's Object. If successful, this method
+ * will invoke a setter method on the underlying Object. The setter is the one
+ * for the specified property name and the value is determined partly from the
+ * setter argument type and partly from the value specified in the call to
+ * this method.
+ *
+ * <p>
+ * If the setter expects a String no conversion is necessary. If it expects an
+ * int, then an attempt is made to convert 'value' to an int using new
+ * Integer(value). If the setter expects a boolean, the conversion is by new
+ * Boolean(value).
+ *
+ * @param name
+ * name of the property
+ * @param value
+ * String value of the property
*/
public void setProperty(String name, String value) {
if (value == null) {
@@ -150,35 +151,37 @@
PropertyDescriptor prop = getPropertyDescriptor(name);
- //LogLog.debug("---------Key: "+name+", type="+prop.getPropertyType());
+ // LogLog.debug("---------Key: "+name+", type="+prop.getPropertyType());
if (prop == null) {
- addWarn(
- "No such property [" + name + "] in " + objClass.getName() + ".");
+ addWarn("No such property [" + name + "] in " + objClass.getName() + ".");
} else {
try {
setProperty(prop, name, value);
} catch (PropertySetterException ex) {
- addWarn(
- "Failed to set property [" + name + "] to value \"" + value + "\". ", ex);
+ addWarn("Failed to set property [" + name + "] to value \"" + value
+ + "\". ", ex);
}
}
}
/**
- Set the named property given a {@link PropertyDescriptor}.
-
- @param prop A PropertyDescriptor describing the characteristics
- of the property to set.
- @param name The named of the property to set.
- @param value The value of the property.
+ * Set the named property given a {@link PropertyDescriptor}.
+ *
+ * @param prop
+ * A PropertyDescriptor describing the characteristics of the
+ * property to set.
+ * @param name
+ * The named of the property to set.
+ * @param value
+ * The value of the property.
*/
public void setProperty(PropertyDescriptor prop, String name, String value)
- throws PropertySetterException {
+ throws PropertySetterException {
Method setter = prop.getWriteMethod();
if (setter == null) {
- throw new PropertySetterException(
- "No setter for property [" + name + "].");
+ throw new PropertySetterException("No setter for property [" + name
+ + "].");
}
Class[] paramTypes = setter.getParameterTypes();
@@ -192,16 +195,16 @@
try {
arg = convertArg(value, paramTypes[0]);
} catch (Throwable t) {
- throw new PropertySetterException(
- "Conversion to type [" + paramTypes[0] + "] failed. ", t);
+ throw new PropertySetterException("Conversion to type [" + paramTypes[0]
+ + "] failed. ", t);
}
if (arg == null) {
- throw new PropertySetterException(
- "Conversion to type [" + paramTypes[0] + "] failed.");
+ throw new PropertySetterException("Conversion to type [" + paramTypes[0]
+ + "] failed.");
}
- //getLogger().debug("Setting property [{}] to [{}].", name, arg);
+ // getLogger().debug("Setting property [{}] to [{}].", name, arg);
try {
setter.invoke(obj, new Object[] { arg });
@@ -216,33 +219,32 @@
Method method = getMethod("add" + cName);
if (method != null) {
- //getLogger().debug(
- // "Found add {} method in class {}", cName, objClass.getName());
+ // getLogger().debug(
+ // "Found add {} method in class {}", cName, objClass.getName());
return AS_COLLECTION;
}
String dName = Introspector.decapitalize(name);
-
+
PropertyDescriptor propertyDescriptor = getPropertyDescriptor(dName);
if (propertyDescriptor != null) {
Method setterMethod = propertyDescriptor.getWriteMethod();
-
if (setterMethod != null) {
- //getLogger().debug(
- // "Found setter method for property [{}] in class {}", name,
- // objClass.getName());
+ // getLogger().debug(
+ // "Found setter method for property [{}] in class {}", name,
+ // objClass.getName());
Class[] classArray = setterMethod.getParameterTypes();
- if(classArray.length != 1) {
+ if (classArray.length != 1) {
return NOT_FOUND;
} else {
Class clazz = classArray[0];
Package p = clazz.getPackage();
- if(clazz.isPrimitive()) {
+ if (clazz.isPrimitive()) {
return AS_PROPERTY;
- } else if("java.lang".equals(p.getName())) {
+ } else if ("java.lang".equals(p.getName())) {
return AS_PROPERTY;
} else {
return AS_COMPONENT;
@@ -255,8 +257,6 @@
return NOT_FOUND;
}
-
-
public Class getObjClass() {
return objClass;
}
@@ -277,28 +277,24 @@
try {
method.invoke(this.obj, new Object[] { childComponent });
} catch (Exception e) {
- addError(
- "Could not invoke method " + method.getName() + " in class "
- + obj.getClass().getName() + " with parameter of type "
- + ccc.getName(), e);
+ addError("Could not invoke method " + method.getName()
+ + " in class " + obj.getClass().getName()
+ + " with parameter of type " + ccc.getName(), e);
}
} else {
- addError(
- "A \"" + ccc.getName() + "\" object is not assignable to a \""
- + params[0].getName() + "\" variable.");
- addError(
- "The class \"" + params[0].getName() + "\" was loaded by ");
- addError(
- "[" + params[0].getClassLoader() + "] whereas object of type ");
- addError(
- "\"" + ccc.getName() + "\" was loaded by [" + ccc.getClassLoader()
- + "].");
+ addError("A \"" + ccc.getName()
+ + "\" object is not assignable to a \"" + params[0].getName()
+ + "\" variable.");
+ addError("The class \"" + params[0].getName() + "\" was loaded by ");
+ addError("[" + params[0].getClassLoader()
+ + "] whereas object of type ");
+ addError("\"" + ccc.getName() + "\" was loaded by ["
+ + ccc.getClassLoader() + "].");
}
}
} else {
- addError(
- "Could not find method [" + "add" + name + "] in class ["
- + objClass.getName() + "].");
+ addError("Could not find method [" + "add" + name + "] in class ["
+ + objClass.getName() + "].");
}
}
@@ -306,9 +302,8 @@
PropertyDescriptor propertyDescriptor = getPropertyDescriptor(name);
if (propertyDescriptor == null) {
- addWarn(
- "Could not find PropertyDescriptor for [" + name + "] in "
- + objClass.getName());
+ addWarn("Could not find PropertyDescriptor for [" + name + "] in "
+ + objClass.getName());
return;
}
@@ -316,9 +311,8 @@
Method setter = propertyDescriptor.getWriteMethod();
if (setter == null) {
- addWarn(
- "Not setter method for property [" + name + "] in "
- + obj.getClass().getName());
+ addWarn("Not setter method for property [" + name + "] in "
+ + obj.getClass().getName());
return;
}
@@ -326,21 +320,20 @@
Class[] paramTypes = setter.getParameterTypes();
if (paramTypes.length != 1) {
- addError(
- "Wrong number of parameters in setter method for property [" + name
- + "] in " + obj.getClass().getName());
+ addError("Wrong number of parameters in setter method for property ["
+ + name + "] in " + obj.getClass().getName());
return;
}
try {
setter.invoke(obj, new Object[] { childComponent });
- //getLogger().debug(
- // "Set child component of type [{}] for [{}].", objClass.getName(),
- // childComponent.getClass().getName());
+ // getLogger().debug(
+ // "Set child component of type [{}] for [{}].", objClass.getName(),
+ // childComponent.getClass().getName());
} catch (Exception e) {
- addError(
- "Could not set component " + obj + " for parent component " + obj, e);
+ addError("Could not set component " + obj + " for parent component "
+ + obj, e);
}
}
@@ -349,9 +342,8 @@
}
/**
- Convert <code>val</code> a String parameter to an object of a
- given type.
- */
+ * Convert <code>val</code> a String parameter to an object of a given type.
+ */
protected Object convertArg(String val, Class type) {
if (val == null) {
return null;
@@ -365,6 +357,10 @@
return new Integer(v);
} else if (Long.TYPE.isAssignableFrom(type)) {
return new Long(v);
+ } else if (Float.TYPE.isAssignableFrom(type)) {
+ return new Float(v);
+ } else if (Double.TYPE.isAssignableFrom(type)) {
+ return new Double(v);
} else if (Boolean.TYPE.isAssignableFrom(type)) {
if ("true".equalsIgnoreCase(v)) {
return Boolean.TRUE;
Added: logback/trunk/logback-core/src/test/input/joran/fruit1.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/input/joran/fruit1.xml Thu Oct 19 15:45:50 2006
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<group>
+ <fruitShell name="fs0">
+ <fruit class="ch.qos.logback.core.joran.replay.Fruit">
+ <name>blue</name>
+ </fruit>
+ </fruitShell>
+</group>
\ No newline at end of file
Added: logback/trunk/logback-core/src/test/input/joran/fruit2.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/input/joran/fruit2.xml Thu Oct 19 15:45:50 2006
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<group>
+ <fruitShell name="fs0">
+ <fruit class="ch.qos.logback.core.joran.replay.Fruit">
+ <name>blue</name>
+ </fruit>
+ </fruitShell>
+
+ <fruitShell name="fs1">
+ <fruit class="ch.qos.logback.core.joran.replay.WeightytFruit">
+ <name>orange</name>
+ <weight>1.2</weight>
+ </fruit>
+ </fruitShell>
+</group>
\ No newline at end of file
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/AllTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/AllTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/AllTest.java Thu Oct 19 15:45:50 2006
@@ -18,11 +18,11 @@
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(ch.qos.logback.core.util.PackageTest.suite());
- suite.addTest(ch.qos.logback.core.pattern.AllTest.suite());
+ suite.addTest(ch.qos.logback.core.pattern.PackageTest.suite());
+ suite.addTest(ch.qos.logback.core.joran.PackageTest.suite());
suite.addTest(ch.qos.logback.core.appender.PackageTest.suite());
suite.addTest(ch.qos.logback.core.rolling.helper.PackageTest.suite());
suite.addTest(ch.qos.logback.core.rolling.PackageTest.suite());
- suite.addTest(ch.qos.logback.core.joran.PackageTest.suite());
return suite;
}
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java Thu Oct 19 15:45:50 2006
@@ -21,6 +21,7 @@
suite.addTestSuite(TrivialcConfiguratorTest.class);
suite.addTest(ch.qos.logback.core.joran.event.PackageTest.suite());
suite.addTest(ch.qos.logback.core.joran.spi.PackageTest.suite());
+ suite.addTest(ch.qos.logback.core.joran.replay.PackageTest.suite());
return suite;
}
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java Thu Oct 19 15:45:50 2006
@@ -42,6 +42,27 @@
assertTrue(listenAction.getSeList().get(1) instanceof StartEvent);
assertTrue(listenAction.getSeList().get(2) instanceof BodyEvent);
assertTrue(listenAction.getSeList().get(3) instanceof EndEvent);
+ }
+
+ public void testReplay() throws JoranException {
+ ListenAction listenAction = new ListenAction();
+
+ rulesMap.put(new Pattern("fire"), listenAction);
+ TrivialConfigurator gc = new TrivialConfigurator(rulesMap);
+
+ gc.setContext(context);
+ gc.doConfigure(Constants.TEST_DIR_PREFIX + "input/joran/fire1.xml");
+ for(SaxEvent se: listenAction.getSeList()) {
+ System.out.println(se);
+ }
+ assertEquals(5, listenAction.getSeList().size());
+ assertTrue(listenAction.getSeList().get(0) instanceof StartEvent);
+ assertTrue(listenAction.getSeList().get(1) instanceof StartEvent);
+ assertTrue(listenAction.getSeList().get(2) instanceof BodyEvent);
+ assertTrue(listenAction.getSeList().get(3) instanceof EndEvent);
}
+
+
+
}
Added: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/Fruit.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/Fruit.java Thu Oct 19 15:45:50 2006
@@ -0,0 +1,28 @@
+package ch.qos.logback.core.joran.replay;
+
+public class Fruit {
+
+ String name;
+
+ public Fruit() {
+ System.out.println("Fruit constructor called");
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String toString() {
+ final String TAB = " ";
+
+ StringBuilder retValue = new StringBuilder();
+
+ retValue.append("xFruit ( ").append("name = ").append(this.name).append(TAB).append(" )");
+
+ return retValue.toString();
+ }
+}
Added: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitAction.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitAction.java Thu Oct 19 15:45:50 2006
@@ -0,0 +1,81 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
+ *
+ * Copyright (C) 2000-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+
+package ch.qos.logback.core.joran.replay;
+
+import org.xml.sax.Attributes;
+
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.spi.ActionException;
+import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.util.OptionHelper;
+
+public class FruitAction extends Action {
+
+ Fruit fruit;
+ private boolean inError = false;
+
+ @Override
+ public void begin(ExecutionContext ec, String name, Attributes attributes)
+ throws ActionException {
+ String className = attributes.getValue(CLASS_ATTRIBUTE);
+
+ // We are just beginning, reset variables
+ fruit = null;
+ inError = false;
+
+ try {
+ addInfo("About to instantiate fruit of type ["+className+"]");
+
+ fruit = (Fruit) OptionHelper.instantiateByClassName(
+ className, ch.qos.logback.core.joran.replay.Fruit.class);
+
+ String fruitName = attributes.getValue(NAME_ATTRIBUTE);
+
+ if (OptionHelper.isEmpty(fruitName)) {
+ addWarn(
+ "No fruit name given for fruit of type " + className + "].");
+ } else {
+ fruit.setName(fruitName);
+ addInfo("Fruit named as [" + fruitName + "]");
+ }
+
+ ec.pushObject(fruit);
+ } catch (Exception oops) {
+ inError = true;
+ addError(
+ "Could not create an Fruit of type ["+className+"].", oops);
+ throw new ActionException(ActionException.SKIP_CHILDREN, oops);
+ }
+
+ }
+
+ @Override
+ public void end(ExecutionContext ec, String name) throws ActionException {
+ if (inError) {
+ return;
+ }
+
+ Object o = ec.peekObject();
+
+ if (o != fruit) {
+ addWarn(
+ "The object at the of the stack is not the fruit named ["
+ + fruit.getName() + "] pushed earlier.");
+ } else {
+ addInfo(
+ "Popping fruit named [" + fruit.getName()
+ + "] from the object stack");
+ ec.popObject();
+ }
+ }
+
+
+}
Added: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitConfigurationTest.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitConfigurationTest.java Thu Oct 19 15:45:50 2006
@@ -0,0 +1,79 @@
+package ch.qos.logback.core.joran.replay;
+
+import java.util.HashMap;
+import java.util.List;
+
+import junit.framework.TestCase;
+import ch.qos.logback.core.joran.NOPAction;
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.spi.Pattern;
+import ch.qos.logback.core.util.Constants;
+import ch.qos.logback.core.util.StatusPrinter;
+
+public class FruitConfigurationTest extends TestCase {
+
+ FruitContext fruitContext = new FruitContext();
+
+ public FruitConfigurationTest(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public List<FruitShell> doFirstPart(String filename) throws Exception {
+
+ HashMap<Pattern, Action> rulesMap = new HashMap<Pattern, Action>();
+ rulesMap.put(new Pattern("group/fruitShell"), new FruitShellAction());
+ rulesMap.put(new Pattern("group/fruitShell/fruit"), new FruitFactoryAction());
+ rulesMap.put(new Pattern("group/fruitShell/fruit/*"), new NOPAction());
+ SimpleConfigurator gc = new SimpleConfigurator(rulesMap);
+
+ gc.setContext(fruitContext);
+
+ gc.doConfigure(Constants.TEST_DIR_PREFIX + "input/joran/" + filename);
+
+ StatusPrinter.print(fruitContext);
+ return fruitContext.getFruitShellList();
+
+ }
+
+ public void test1() throws Exception {
+ List<FruitShell> fsList = doFirstPart("fruit1.xml");
+ assertNotNull(fsList);
+ assertEquals(1, fsList.size());
+
+ FruitShell fs0 = fsList.get(0);
+ assertNotNull(fs0);
+ assertEquals("fs0", fs0.getName());
+ Fruit fruit0 = fs0.fruitFactory.buildFruit();
+ assertTrue(fruit0 instanceof Fruit);
+ assertEquals("blue", fruit0.getName());
+ }
+
+ public void test2() throws Exception {
+ List<FruitShell> fsList = doFirstPart("fruit2.xml");
+ assertNotNull(fsList);
+ assertEquals(2, fsList.size());
+
+ FruitShell fs0 = fsList.get(0);
+ assertNotNull(fs0);
+ assertEquals("fs0", fs0.getName());
+ Fruit fruit0 = fs0.fruitFactory.buildFruit();
+ assertTrue(fruit0 instanceof Fruit);
+ assertEquals("blue", fruit0.getName());
+
+ FruitShell fs1 = fsList.get(1);
+ assertNotNull(fs1);
+ assertEquals("fs1", fs1.getName());
+ Fruit fruit1 = fs1.fruitFactory.buildFruit();
+ assertTrue(fruit1 instanceof WeightytFruit);
+ assertEquals("orange", fruit1.getName());
+ assertEquals(1.2, ((WeightytFruit) fruit1).getWeight());
+ }
+}
Added: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitConfigurator.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitConfigurator.java Thu Oct 19 15:45:50 2006
@@ -0,0 +1,58 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework.
+ *
+ * Copyright (C) 1999-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+package ch.qos.logback.core.joran.replay;
+
+import java.util.List;
+
+import ch.qos.logback.core.joran.GenericConfigurator;
+import ch.qos.logback.core.joran.NOPAction;
+import ch.qos.logback.core.joran.action.NestedComponentIA;
+import ch.qos.logback.core.joran.action.NestedSimplePropertyIA;
+import ch.qos.logback.core.joran.event.SaxEvent;
+import ch.qos.logback.core.joran.spi.EventPlayer;
+import ch.qos.logback.core.joran.spi.Interpreter;
+import ch.qos.logback.core.joran.spi.JoranException;
+import ch.qos.logback.core.joran.spi.Pattern;
+import ch.qos.logback.core.joran.spi.RuleStore;
+
+public class FruitConfigurator extends GenericConfigurator {
+
+ FruitFactory ff;
+ public FruitConfigurator(FruitFactory ff) {
+ this.ff = ff;
+ }
+
+ @Override
+ final public void doConfigure(final List<SaxEvent> eventList)
+ throws JoranException {
+ buildInterpreter();
+ interpreter.getExecutionContext().pushObject(ff);
+ EventPlayer player = new EventPlayer(interpreter);
+ player.play(eventList);
+ }
+
+ @Override
+ protected void addImplicitRules(Interpreter interpreter) {
+ NestedComponentIA nestedIA = new NestedComponentIA();
+ nestedIA.setContext(context);
+ interpreter.addImplicitAction(nestedIA);
+
+ NestedSimplePropertyIA nestedSimpleIA = new NestedSimplePropertyIA();
+ nestedIA.setContext(context);
+ interpreter.addImplicitAction(nestedSimpleIA);
+ }
+
+
+ @Override
+ protected void addInstanceRules(RuleStore rs) {
+ rs.addRule(new Pattern("fruitShell"), new NOPAction());
+ }
+
+}
Added: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitContext.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitContext.java Thu Oct 19 15:45:50 2006
@@ -0,0 +1,23 @@
+package ch.qos.logback.core.joran.replay;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import ch.qos.logback.core.ContextBase;
+
+public class FruitContext extends ContextBase {
+
+ List<FruitShell> fruitShellList = new ArrayList<FruitShell>();
+
+ public void addFruitShell(FruitShell fs) {
+ fruitShellList.add(fs);
+ }
+
+ public List<FruitShell> getFruitShellList() {
+ return fruitShellList;
+ }
+
+ public void setFruitShellList(List<FruitShell> fruitShellList) {
+ this.fruitShellList = fruitShellList;
+ }
+}
Added: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitFactory.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitFactory.java Thu Oct 19 15:45:50 2006
@@ -0,0 +1,49 @@
+package ch.qos.logback.core.joran.replay;
+
+import java.util.List;
+
+import ch.qos.logback.core.Context;
+import ch.qos.logback.core.ContextBase;
+import ch.qos.logback.core.joran.event.SaxEvent;
+import ch.qos.logback.core.joran.spi.JoranException;
+
+public class FruitFactory {
+
+ List<SaxEvent> eventList;
+ Fruit fruit;
+
+ public void setFruit(Fruit fruit) {
+ this.fruit = fruit;
+ }
+
+ public Fruit buildFruit() {
+ for (SaxEvent se : eventList) {
+ System.out.println(se);
+ }
+ Context context = new ContextBase();
+ this.fruit = null;
+ FruitConfigurator fruitConfigurator = new FruitConfigurator(this);
+ fruitConfigurator.setContext(context);
+ try {
+ fruitConfigurator.doConfigure(eventList);
+ } catch(JoranException je) {
+ je.printStackTrace();
+ }
+ return fruit;
+ }
+
+ public String toString() {
+ final String TAB = " ";
+
+ StringBuilder retValue = new StringBuilder();
+
+ retValue.append("FruitFactory ( ");
+ if (eventList != null && eventList.size() > 0) {
+ retValue.append("event1 = ").append(eventList.get(0)).append(TAB);
+ }
+ retValue.append(" )");
+
+ return retValue.toString();
+ }
+
+}
Added: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitFactoryAction.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitFactoryAction.java Thu Oct 19 15:45:50 2006
@@ -0,0 +1,55 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
+ *
+ * Copyright (C) 2000-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+
+package ch.qos.logback.core.joran.replay;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.xml.sax.Attributes;
+
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.event.InPlayListener;
+import ch.qos.logback.core.joran.event.SaxEvent;
+import ch.qos.logback.core.joran.spi.ActionException;
+import ch.qos.logback.core.joran.spi.ExecutionContext;
+
+public class FruitFactoryAction extends Action implements InPlayListener {
+
+ List<SaxEvent> seList = new ArrayList<SaxEvent>();
+
+ @Override
+ public void begin(ExecutionContext ec, String name, Attributes attributes)
+ throws ActionException {
+ ec.addInPlayListener(this);
+ }
+
+ @Override
+ public void end(ExecutionContext ec, String name) throws ActionException {
+ ec.removeInPlayListener(this);
+
+ Object o = ec.peekObject();
+ if(o instanceof FruitShell) {
+ FruitShell fs = (FruitShell) o;
+ FruitFactory fruitFactory = new FruitFactory();
+ fruitFactory.eventList = new ArrayList<SaxEvent>(seList);
+ fs.setFruitFactory(fruitFactory);
+ }
+ }
+
+ public void inPlay(SaxEvent event) {
+ seList.add(event);
+ }
+
+ public List<SaxEvent> getSeList() {
+ return seList;
+ }
+
+}
Added: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitShell.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitShell.java Thu Oct 19 15:45:50 2006
@@ -0,0 +1,49 @@
+package ch.qos.logback.core.joran.replay;
+
+import ch.qos.logback.core.spi.ContextAwareBase;
+
+public class FruitShell extends ContextAwareBase {
+
+ FruitFactory fruitFactory;
+ String name;
+
+ public void setFruitFactory(FruitFactory fruitFactory) {
+ this.fruitFactory = fruitFactory;
+ }
+
+ void testFruit() {
+
+ Fruit fruit = fruitFactory.buildFruit();
+ System.out.println(fruit);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Constructs a <code>String</code> with all attributes
+ * in name = value format.
+ *
+ * @return a <code>String</code> representation
+ * of this object.
+ */
+ public String toString()
+ {
+ final String TAB = " ";
+
+ String retValue = "";
+
+ retValue = "FruitShell ( "
+ + "fruitFactory = " + this.fruitFactory + TAB
+ + "name = " + this.name + TAB
+ + " )";
+
+ return retValue;
+ }
+
+}
Added: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitShellAction.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitShellAction.java Thu Oct 19 15:45:50 2006
@@ -0,0 +1,81 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
+ *
+ * Copyright (C) 2000-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+
+package ch.qos.logback.core.joran.replay;
+
+import org.xml.sax.Attributes;
+
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.spi.ActionException;
+import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.util.OptionHelper;
+
+public class FruitShellAction extends Action {
+
+ FruitShell fruitShell;
+ private boolean inError = false;
+
+
+ @Override
+ public void begin(ExecutionContext ec, String name, Attributes attributes)
+ throws ActionException {
+
+ // We are just beginning, reset variables
+ fruitShell = new FruitShell();
+ inError = false;
+
+ try {
+
+
+ fruitShell.setContext(context);
+
+ String shellName = attributes.getValue(NAME_ATTRIBUTE);
+
+ if (OptionHelper.isEmpty(shellName)) {
+ addWarn(
+ "No appender name given for fruitShell].");
+ } else {
+ fruitShell.setName(shellName);
+ addInfo("FruitShell named as [" + shellName + "]");
+ }
+
+ ec.pushObject(fruitShell);
+ } catch (Exception oops) {
+ inError = true;
+ addError(
+ "Could not create an FruitShell", oops);
+ throw new ActionException(ActionException.SKIP_CHILDREN, oops);
+ }
+ }
+
+ @Override
+ public void end(ExecutionContext ec, String name) throws ActionException {
+ if (inError) {
+ return;
+ }
+
+ Object o = ec.peekObject();
+
+ if (o != fruitShell) {
+ addWarn(
+ "The object at the of the stack is not the fruitShell named ["
+ + fruitShell.getName() + "] pushed earlier.");
+ } else {
+ addInfo(
+ "Popping fruitSHell named [" + fruitShell.getName()
+ + "] from the object stack");
+ ec.popObject();
+ FruitContext fruitContext = (FruitContext) ec.getContext();
+ fruitContext.addFruitShell(fruitShell);
+ }
+ }
+
+
+}
Added: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/PackageTest.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/PackageTest.java Thu Oct 19 15:45:50 2006
@@ -0,0 +1,23 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
+ *
+ * Copyright (C) 2000-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+package ch.qos.logback.core.joran.replay;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class PackageTest extends TestCase {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ suite.addTestSuite(FruitConfigurationTest.class);
+ return suite;
+ }
+}
Added: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/SimpleConfigurator.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/SimpleConfigurator.java Thu Oct 19 15:45:50 2006
@@ -0,0 +1,49 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework.
+ *
+ * Copyright (C) 1999-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+package ch.qos.logback.core.joran.replay;
+
+import java.util.HashMap;
+
+import ch.qos.logback.core.joran.GenericConfigurator;
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.action.NestedComponentIA;
+import ch.qos.logback.core.joran.action.NestedSimplePropertyIA;
+import ch.qos.logback.core.joran.spi.Interpreter;
+import ch.qos.logback.core.joran.spi.Pattern;
+import ch.qos.logback.core.joran.spi.RuleStore;
+
+public class SimpleConfigurator extends GenericConfigurator {
+
+ HashMap<Pattern, Action> rulesMap;
+
+ public SimpleConfigurator(HashMap<Pattern, Action> rules) {
+ this.rulesMap = rules;
+ }
+
+ @Override
+ protected void addImplicitRules(Interpreter interpreter) {
+ NestedComponentIA nestedIA = new NestedComponentIA();
+ nestedIA.setContext(context);
+ interpreter.addImplicitAction(nestedIA);
+
+ NestedSimplePropertyIA nestedSimpleIA = new NestedSimplePropertyIA();
+ nestedIA.setContext(context);
+ interpreter.addImplicitAction(nestedSimpleIA);
+ }
+
+ @Override
+ protected void addInstanceRules(RuleStore rs) {
+ for(Pattern pattern : rulesMap.keySet()) {
+ Action action = rulesMap.get(pattern);
+ rs.addRule(pattern, action);
+ }
+ }
+
+}
Added: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/WeightytFruit.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/WeightytFruit.java Thu Oct 19 15:45:50 2006
@@ -0,0 +1,16 @@
+package ch.qos.logback.core.joran.replay;
+
+public class WeightytFruit extends Fruit {
+
+ double weight;
+
+ public double getWeight() {
+ return weight;
+ }
+
+ public void setWeight(double weight) {
+ this.weight = weight;
+ }
+
+
+}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PatternTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PatternTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PatternTest.java Thu Oct 19 15:45:50 2006
@@ -13,7 +13,6 @@
import ch.qos.logback.core.joran.spi.Pattern;
import junit.framework.TestCase;
-
/**
* Test pattern manipulation code.
*
@@ -22,6 +21,7 @@
public class PatternTest extends TestCase {
/**
* Constructor for PatternTestCase.
+ *
* @param name
*/
public PatternTest(String name) {
@@ -85,6 +85,67 @@
assertEquals("a", p.get(0));
assertEquals("b", p.get(1));
}
+
+
+ // test tail matching
+ public void testTailMatch() {
+ {
+ Pattern p = new Pattern("/a/b");
+ Pattern rulePattern = new Pattern("*");
+ assertEquals(0, p.getTailMatchLength(rulePattern));
+ }
+
+ {
+ Pattern p = new Pattern("/a");
+ Pattern rulePattern = new Pattern("*/a");
+ assertEquals(1, p.getTailMatchLength(rulePattern));
+ }
+
+ {
+ Pattern p = new Pattern("/a/b");
+ Pattern rulePattern = new Pattern("*/b");
+ assertEquals(1, p.getTailMatchLength(rulePattern));
+ }
+
+
+ {
+ Pattern p = new Pattern("/a/b/c");
+ Pattern rulePattern = new Pattern("*/b/c");
+ assertEquals(2, p.getTailMatchLength(rulePattern));
+ }
+ }
+ // test prefix matching
+ public void testPrefixMatch() {
+ {
+ Pattern p = new Pattern("/a/b");
+ Pattern rulePattern = new Pattern("/x/*");
+ assertEquals(0, p.getPrefixMatchLength(rulePattern));
+ }
+
+ {
+ Pattern p = new Pattern("/a");
+ Pattern rulePattern = new Pattern("/x/*");
+ assertEquals(0, p.getPrefixMatchLength(rulePattern));
+ }
+
+ {
+ Pattern p = new Pattern("/a/b");
+ Pattern rulePattern = new Pattern("/a/*");
+ assertEquals(2, p.getPrefixMatchLength(rulePattern));
+ }
+
+ {
+ Pattern p = new Pattern("/a/b");
+ Pattern rulePattern = new Pattern("/a/b/*");
+ assertEquals(2, p.getPrefixMatchLength(rulePattern));
+ }
+
+ {
+ Pattern p = new Pattern("/a/b");
+ Pattern rulePattern = new Pattern("/*");
+ assertEquals(1, p.getPrefixMatchLength(rulePattern));
+ }
+ }
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/SimpleStoreTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/SimpleStoreTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/SimpleStoreTest.java Thu Oct 19 15:45:50 2006
@@ -10,22 +10,14 @@
package ch.qos.logback.core.joran.spi;
+import java.util.List;
+
import junit.framework.TestCase;
-import org.w3c.dom.Document;
import org.xml.sax.Attributes;
import ch.qos.logback.core.ContextBase;
import ch.qos.logback.core.joran.action.Action;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
-import ch.qos.logback.core.joran.spi.Pattern;
-import ch.qos.logback.core.joran.spi.SimpleRuleStore;
-
-
-import java.util.List;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
/**
*
@@ -58,7 +50,7 @@
assertEquals(1, r.size());
if (!(r.get(0) instanceof XAction)) {
- fail("Wring type");
+ fail("Wrong type");
}
srs = new SimpleRuleStore(new ContextBase());
@@ -91,7 +83,7 @@
assertEquals(1, r.size());
if (!(r.get(0) instanceof XAction)) {
- fail("Wring type");
+ fail("Wrong type");
}
}
@@ -107,7 +99,7 @@
assertEquals(1, r.size());
if (!(r.get(0) instanceof YAction)) {
- fail("Wring type");
+ fail("Wrong type");
}
}
@@ -124,19 +116,25 @@
assertEquals(1, r.size());
if (!(r.get(0) instanceof ZAction)) {
- fail("Wring type");
+ fail("Wrong type");
}
}
+
+ public void testSuffix() throws Exception {
+ SimpleRuleStore srs = new SimpleRuleStore(new ContextBase());
+ srs.addRule(new Pattern("a"), new XAction());
+ srs.addRule(new Pattern("a/*"), new YAction());
- Document getW3Document(String file) throws Exception {
- DocumentBuilderFactory dbf = null;
- dbf = DocumentBuilderFactory.newInstance();
+ List r = srs.matchActions(new Pattern("a/b"));
+ assertNotNull(r);
- DocumentBuilder docBuilder = dbf.newDocumentBuilder();
+ assertEquals(1, r.size());
- // inputSource.setSystemId("dummy://log4j.dtd");
- return docBuilder.parse(file);
+ if (!(r.get(0) instanceof YAction)) {
+ fail("Wrong type");
+ }
}
+
class XAction extends Action {
public void begin(ExecutionContext ec, String name, Attributes attributes) {
Copied: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/PackageTest.java (from r714, /logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/AllTest.java)
==============================================================================
--- /logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/AllTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/PackageTest.java Thu Oct 19 15:45:50 2006
@@ -1,14 +1,12 @@
package ch.qos.logback.core.pattern;
-
-
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-public class AllTest extends TestCase {
+public class PackageTest extends TestCase {
- public static Test suite() {
+ public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(ch.qos.logback.core.pattern.parser.PackageTest.suite());
return suite;
1
0
Author: seb
Date: Wed Oct 18 19:51:35 2006
New Revision: 714
Added:
logback/trunk/src/site/
logback/trunk/src/site/site.xml
Log:
back online, was useful...
Added: logback/trunk/src/site/site.xml
==============================================================================
--- (empty file)
+++ logback/trunk/src/site/site.xml Wed Oct 18 19:51:35 2006
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project name="LOGBack Main Site">
+
+ <skin>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-skin</artifactId>
+ <version>0.3</version>
+ </skin>
+ <!--
+ <publishDate position="navigation-bottom" format="dd-MM-yyyy"/>
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ <src>/images/logos/lblogo.jpg</src>
+ </bannerLeft>
+
+ <body>
+ <links>
+ <item name="Core Module" href="http://logback.qos.ch/core/" />
+ <item name="Classic Module" href="http://logback.qos.ch/classic/"/>
+ <item name="Access Module" href="http://logback.qos.ch/access/"/>
+ </links>
+
+ <menu name="${project.name}">
+ <item name="Introduction" href="index.html"/>
+ <item name="News" href="news.html" />
+ <item name="Download" href="download.html" />
+ <item name="Documentation" href="documentation.html" />
+ <item name="Mailing Lists" href="mailinglist.html" />
+ <item name="Source Repository" href="repos.html" />
+ <item name="Bug Report" href="bugreport.html"/>
+ <item name="License" href="license.html" />
+ </menu>
+ </body>
+ -->
+</project>
\ No newline at end of file
1
0
Author: seb
Date: Wed Oct 18 19:44:16 2006
New Revision: 713
Removed:
logback/trunk/src/site/
Log:
removed unused file
1
0

svn commit: r712 - in logback/trunk/logback-core/src: main/java/ch/qos/logback/core/joran main/java/ch/qos/logback/core/joran/spi test/java/ch/qos/logback/core/joran/event
by noreply.ceki@qos.ch 18 Oct '06
by noreply.ceki@qos.ch 18 Oct '06
18 Oct '06
Author: ceki
Date: Wed Oct 18 18:07:22 2006
New Revision: 712
Added:
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/FruitConfigAction.java
Modified:
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java
Log:
Let listener action get the begin action immediately prior to their registration.
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java Wed Oct 18 18:07:22 2006
@@ -30,9 +30,8 @@
public abstract class GenericConfigurator extends ContextAwareBase {
- List<SaxEvent> saxEventList;
Interpreter interpreter;
-
+
final public void doConfigure(URL url) throws JoranException {
try {
InputStream in = url.openStream();
@@ -65,7 +64,7 @@
} catch (java.io.IOException ioe) {
String errMsg = "Could not close [" + file.getName() + "].";
addError(errMsg, ioe);
- throw new JoranException(errMsg,ioe);
+ throw new JoranException(errMsg, ioe);
}
}
}
@@ -76,8 +75,9 @@
}
abstract protected void addInstanceRules(RuleStore rs);
+
abstract protected void addImplicitRules(Interpreter interpreter);
-
+
protected void buildInterpreter() {
RuleStore rs = new SimpleRuleStore(context);
addInstanceRules(rs);
@@ -85,21 +85,23 @@
ExecutionContext ec = interpreter.getExecutionContext();
ec.setContext(context);
addImplicitRules(interpreter);
-
+
}
-
+
final public void doConfigure(final InputSource inputSource)
throws JoranException {
SaxEventRecorder recorder = new SaxEventRecorder();
recorder.setContext(context);
- saxEventList = recorder.recordEvents(inputSource);
+ recorder.recordEvents(inputSource);
buildInterpreter();
EventPlayer player = new EventPlayer(interpreter);
player.play(recorder.saxEventList);
}
- public List<SaxEvent> getSaxEventList() {
- return saxEventList;
+ final public void doConfigure(final List<SaxEvent> eventList)
+ throws JoranException {
+ buildInterpreter();
+ EventPlayer player = new EventPlayer(interpreter);
+ player.play(eventList);
}
-
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java Wed Oct 18 18:07:22 2006
@@ -28,9 +28,9 @@
for(SaxEvent se : seList) {
if(se instanceof StartEvent) {
- // invoke fireInPlay before startElement processing
- interpreter.getExecutionContext().fireInPlay(se);
interpreter.startElement((StartEvent) se);
+ // invoke fireInPlay after startElement processing
+ interpreter.getExecutionContext().fireInPlay(se);
}
if(se instanceof BodyEvent) {
// invoke fireInPlay before characters processing
@@ -38,9 +38,9 @@
interpreter.characters((BodyEvent) se);
}
if(se instanceof EndEvent) {
- interpreter.endElement((EndEvent) se);
- // invoke fireInPlay after endElement processing
+ // invoke fireInPlay before endElement processing
interpreter.getExecutionContext().fireInPlay(se);
+ interpreter.endElement((EndEvent) se);
}
}
Added: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/FruitConfigAction.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/FruitConfigAction.java Wed Oct 18 18:07:22 2006
@@ -0,0 +1,46 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
+ *
+ * Copyright (C) 2000-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+
+package ch.qos.logback.core.joran.event;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.xml.sax.Attributes;
+
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.spi.ActionException;
+import ch.qos.logback.core.joran.spi.ExecutionContext;
+
+public class FruitConfigAction extends Action implements InPlayListener {
+
+ List<SaxEvent> seList = new ArrayList<SaxEvent>();
+
+ @Override
+ public void begin(ExecutionContext ec, String name, Attributes attributes)
+ throws ActionException {
+ ec.addInPlayListener(this);
+ }
+
+ @Override
+ public void end(ExecutionContext ec, String name) throws ActionException {
+ ec.removeInPlayListener(this);
+
+ }
+
+ public void inPlay(SaxEvent event) {
+ seList.add(event);
+ }
+
+ public List<SaxEvent> getSeList() {
+ return seList;
+ }
+
+}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java Wed Oct 18 18:07:22 2006
@@ -34,10 +34,14 @@
gc.setContext(context);
gc.doConfigure(Constants.TEST_DIR_PREFIX + "input/joran/fire1.xml");
- assertEquals(3, listenAction.getSeList().size());
+ for(SaxEvent se: listenAction.getSeList()) {
+ System.out.println(se);
+ }
+ assertEquals(5, listenAction.getSeList().size());
assertTrue(listenAction.getSeList().get(0) instanceof StartEvent);
- assertTrue(listenAction.getSeList().get(1) instanceof BodyEvent);
- assertTrue(listenAction.getSeList().get(2) instanceof EndEvent);
+ assertTrue(listenAction.getSeList().get(1) instanceof StartEvent);
+ assertTrue(listenAction.getSeList().get(2) instanceof BodyEvent);
+ assertTrue(listenAction.getSeList().get(3) instanceof EndEvent);
}
}
1
0

svn commit: r711 - logback/trunk/logback-core/src/test/input/joran
by noreply.ceki@qos.ch 18 Oct '06
by noreply.ceki@qos.ch 18 Oct '06
18 Oct '06
Author: ceki
Date: Wed Oct 18 17:23:27 2006
New Revision: 711
Added:
logback/trunk/logback-core/src/test/input/joran/fire1.xml
Log:
added missing file
Added: logback/trunk/logback-core/src/test/input/joran/fire1.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/input/joran/fire1.xml Wed Oct 18 17:23:27 2006
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<fire>
+ <x>abc</x>
+</fire>
1
0

svn commit: r710 - logback/trunk/logback-site/src/site/xdocTemplates/manual
by noreply.seb@qos.ch 18 Oct '06
by noreply.seb@qos.ch 18 Oct '06
18 Oct '06
Author: seb
Date: Wed Oct 18 17:20:01 2006
New Revision: 710
Modified:
logback/trunk/logback-site/src/site/xdocTemplates/manual/layouts.xml
Log:
work in progress
Modified: logback/trunk/logback-site/src/site/xdocTemplates/manual/layouts.xml
==============================================================================
--- logback/trunk/logback-site/src/site/xdocTemplates/manual/layouts.xml (original)
+++ logback/trunk/logback-site/src/site/xdocTemplates/manual/layouts.xml Wed Oct 18 17:20:01 2006
@@ -346,18 +346,31 @@
conversion specifier's options to configure the depth of
the information to be displayed.
</p>
- <p>For example, <em>%caller{2}</em> would display the following excerpt:</p>
+ <p>For example, <b>%caller{2}</b> would display the following excerpt:</p>
<div class="source">0 [main] DEBUG - logging statement Caller+0 \
at mainPackage.sub.sample.Bar.sampleMethodName(Bar.java:22)
Caller+1 at mainPackage.sub.sample.Bar.createLoggingRequest(Bar.java:17)</div>
- <p>And <em>%caller{3}</em> would display this other excerpt:</p>
+ <p>And <b>%caller{3}</b> would display this other excerpt:</p>
<div class="source">16 [main] DEBUG - logging statement Caller+0 \
at mainPackage.sub.sample.Bar.sampleMethodName(Bar.java:22)
Caller+1 at mainPackage.sub.sample.Bar.createLoggingRequest(Bar.java:17)
Caller+2 at mainPackage.ConfigTester.main(ConfigTester.java:38)</div>
<p>
+ This conversion word can also use evaluators to test logging events
+ against a given criteria before creating the output. For example,
+ using <b>%caller{3, CALLER_DISPLAY_EVAL}</b> will display three lines
+ of stacktrace, only if the evaluator called <em>CALLER_DISPLAY_EVAL</em>
+ returns a <b>positive</b> answer.
+ This behaviour comes from the fact that displaying
+ caller data is very expensive, and one should generally not display it
+ unless the evaluator would return a positive value.
+ </p>
+ <p>Evaluators are described
+ further down this document.
+ </p>
+ <p>
The location information can be very useful.
However, it's generation is
<em>extremely</em>
@@ -497,7 +510,7 @@
If no additional sub-option is specified, then
the entire contents of the MDC key value pair
set is output using a format key1=val1,
- key2=val2
+ key2=val2.
</p>
<p>
@@ -521,13 +534,26 @@
Used to output the Throwable trace that has been
bound to the LoggingEvent, by default this will
output the full trace as one would normally find
- by a call to Throwable.printStackTrace(). The
+ by a call to Throwable.printStackTrace().
+ </p>
+ <p>The
throwable conversion word can be followed by an
option in the form
<b>%throwable{short}</b>
which will only output the first line of the
ThrowableInformation.
</p>
+
+ <p>
+ This conversion word can also use evaluators to test logging events
+ against a given criteria before creating the output. For example,
+ using <b>%ex{full, EX_DISPLAY_EVAL}</b> will display the full
+ stacktrace of the exception, only if the evaluator called <em>EX_DISPLAY_EVAL</em>
+ returns a <b>negative</b> answer. This behaviour comes from the fact that
+ throwable data is generally displayed unless the evaluator would
+ return a positive value. Evaluators are described
+ further down this document.
+ </p>
</td>
</tr>
@@ -654,14 +680,15 @@
<p>
A conversion specifier can be followed by options between
- curled brackets. We have already seen some of the
+ braces. We have already seen some of the
possibilities offered by logback's option handling with, for
example, the MDC conversion specifier:
<em>%mdc{someKey}</em>
.
</p>
- <p>However, there is much more to it than that.</p>
+ <p>However, there is more to it than that.</p>
+ <p><b>ADD OPTIONS EXAMPLES</b></p>
<h4>Evaluators</h4>
<p>
@@ -1021,18 +1048,23 @@
<td align="center"><b>reqParameter{paramName}</b></td>
<td>
<p>
- Parameter of the response. This conversion word can be followed by a key
- whose corresponding data will be extracted from the header information.
+ Parameter of the response.
</p>
+ <p>This conversion word takes the first option in braces and looks
+ for the corresponding parameter in the request.</p>
+ <p><b>%reqParameter{input_data}</b>
+ displays the corresponding parameter.</p>
</td>
</tr>
<tr>
<td align="center"><b>i{header} / header{header}</b></td>
<td>
<p>
- Request header. Just like the reqParameter
- conversion word, reqParameter can be followed by a key.
+ Request header.
</p>
+ <p>This conversion word takes the first option in braces and looks
+ for the corresponding header in the request.</p>
+ <p><b>%header{Referer}</b> displays the referer of the request.</p>
</td>
</tr>
<tr>
@@ -1062,9 +1094,32 @@
<tr>
<td align="center"><b>t / date</b></td>
<td>
- <p>
- Date of the event.
- </p>
+ <p>
+ Used to output the date of the logging event.
+ The date conversion specifier may be followed by
+ a set of braces containing a date and time
+ pattern strings used by
+ <code>java.text.SimpleDateFormat</code>
+ .
+ <em>ABSOLUTE</em>
+ ,
+ <em>DATE</em>
+ or
+ <em>ISO8601</em>
+ can also be used.
+ </p>
+ <p>
+ For example,
+ <b>%d{HH:mm:ss,SSS}</b>
+ ,
+ <b>
+ %d{dd MMM yyyy ;HH:mm:ss,SSS}
+ </b>
+ or
+ <b>%d{DATE}</b>
+ . If no date format specifier is given then
+ ISO8601 format is assumed.
+ </p>
</td>
</tr>
<tr>
@@ -1103,27 +1158,34 @@
<td align="center"><b>reqAttribute{attributeName}</b></td>
<td>
<p>
- Attribute of the request. Just like the reqParameter
- conversion word, reqAttribute can be followed by a key.
- </p>
+ Attribute of the request.
+ </p>^
+ <p>This conversion word takes the first option in braces and looks
+ for the corresponding attribute in the request.</p>
+ <p><b>%reqAttribute{SOME_ATTRIBUTE}</b>
+ displays the corresponding attribute.</p>
</td>
</tr>
<tr>
<td align="center"><b>reqCookie{cookie}</b></td>
<td>
<p>
- Request cookie. Just like the reqParameter
- conversion word, reqCookie can be followed by a key.
+ Request cookie.
</p>
+ <p>This conversion word takes the first option in braces and looks
+ for the corresponding cookie in the request.</p>
+ <p><b>%cookie{COOKIE_NAME}</b> displays corresponding cookie.</p>
</td>
</tr>
<tr>
<td align="center"><b>responseHeader{header}</b></td>
<td>
<p>
- Header of the response. Just like the reqParameter
- conversion word, responseHeader can be followed by a key.
+ Header of the response.
</p>
+ <p>This conversion word takes the first option in braces and looks
+ for the corresponding header in the response.</p>
+ <p><b>%header{Referer}</b> displays the referer of the response.</p>
</td>
</tr>
</table>
1
0
Author: ceki
Date: Wed Oct 18 16:22:03 2006
New Revision: 709
Added:
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/BodyEvent.java
- copied, changed from r706, /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/BodyEvent.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/EndEvent.java
- copied, changed from r706, /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EndEvent.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/InPlayListener.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEvent.java
- copied, changed from r706, /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SaxEvent.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEventRecorder.java
- copied, changed from r706, /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SaxEventRecorder.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/StartEvent.java
- copied, changed from r706, /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/StartEvent.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/EventRecorderTest.java
- copied, changed from r706, /logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/EventRecorderTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/ListenAction.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/PackageTest.java
Removed:
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/BodyEvent.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EndEvent.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SaxEvent.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SaxEventRecorder.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/StartEvent.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/EventRecorderTest.java
Modified:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/LoggerStatusPrinter.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/JoranConfiguratorBase.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/Action.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ActionException.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ExecutionContext.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/AllTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialConfigurator.java
Log:
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java Wed Oct 18 16:22:03 2006
@@ -1,11 +1,11 @@
/**
- * LOGBack: the reliable, fast and flexible logging library for Java.
- *
- * Copyright (C) 1999-2005, QOS.ch, LOGBack.com
- *
- * This library is free software, you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation.
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
+ *
+ * Copyright (C) 2000-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
*/
package ch.qos.logback.classic;
@@ -25,19 +25,20 @@
import ch.qos.logback.core.spi.AppenderAttachable;
import ch.qos.logback.core.spi.AppenderAttachableImpl;
-
-public final class Logger implements org.slf4j.Logger, AppenderAttachable, Serializable {
+public final class Logger implements org.slf4j.Logger, AppenderAttachable,
+ Serializable {
/**
- *
- */
- private static final long serialVersionUID = 5454405123156820674L;
+ *
+ */
+ private static final long serialVersionUID = 5454405123156820674L;
- /**
+ /**
* The fully qualified name of this class. Used in gathering caller
* information.
*/
- public static final String FQCN = ch.qos.logback.classic.Logger.class.getName();
+ public static final String FQCN = ch.qos.logback.classic.Logger.class
+ .getName();
static int instanceCount = 0;
@@ -79,7 +80,7 @@
// loggerRemoteView cannot be final because it may change as a consequence
// of changes in LoggerContext
LoggerRemoteView loggerRemoteView;
-
+
Logger(String name, Logger parent, LoggerContext loggerContext) {
this.name = name;
this.parent = parent;
@@ -275,7 +276,7 @@
// No appenders in hierarchy
if (writes == 0) {
- loggerContext.noAppenderDefinedWarning(this);
+ loggerContext.noAppenderDefinedWarning(this);
}
}
@@ -363,10 +364,9 @@
}
/**
- * The next three methods could be merged.
- * However, we decided not to merge them to make the calls to
- * these methods more easily understandable, avoiding many instances
- * of passing null parameters.
+ * The next three methods could be merged. However, we decided not to merge
+ * them to make the calls to these methods more easily understandable,
+ * avoiding many instances of passing null parameters.
*/
private void filterAndLog(String caller, Level level, String format,
Throwable t) {
@@ -401,19 +401,19 @@
public void debug(String format, Object arg) {
if (isDebugEnabled()) {
- filterAndLog(FQCN, Level.DEBUG, format, new Object[] {arg}, null);
+ filterAndLog(FQCN, Level.DEBUG, format, new Object[] { arg }, null);
}
}
public void debug(String format, Object arg1, Object arg2) {
if (isDebugEnabled()) {
- filterAndLog(FQCN, Level.DEBUG, format, new Object[] {arg1, arg2}, null);
+ filterAndLog(FQCN, Level.DEBUG, format, new Object[] { arg1, arg2 }, null);
}
}
public void debug(String format, Object[] argArray) {
if (isDebugEnabled()) {
- filterAndLog(FQCN, Level.DEBUG, format, new Object[] {argArray}, null);
+ filterAndLog(FQCN, Level.DEBUG, format, new Object[] { argArray }, null);
}
}
@@ -431,21 +431,22 @@
public void debug(Marker marker, String format, Object arg) {
if (isDebugEnabled()) {
- filterAndLog(FQCN, Level.DEBUG, marker, format, new Object[] {arg}, null);
+ filterAndLog(FQCN, Level.DEBUG, marker, format, new Object[] { arg },
+ null);
}
}
public void debug(Marker marker, String format, Object arg1, Object arg2) {
if (isDebugEnabled()) {
filterAndLog(FQCN, Level.DEBUG, marker, format,
- new Object[] {arg1, arg2}, null);
+ new Object[] { arg1, arg2 }, null);
}
}
public void debug(Marker marker, String format, Object[] argArray) {
if (isDebugEnabled()) {
- filterAndLog(FQCN, Level.DEBUG, marker, format, new Object[] {argArray},
- null);
+ filterAndLog(FQCN, Level.DEBUG, marker, format,
+ new Object[] { argArray }, null);
}
}
@@ -463,19 +464,19 @@
public void error(String format, Object arg) {
if (isErrorEnabled()) {
- filterAndLog(FQCN, Level.ERROR, format, new Object[] {arg}, null);
+ filterAndLog(FQCN, Level.ERROR, format, new Object[] { arg }, null);
}
}
public void error(String format, Object arg1, Object arg2) {
if (isErrorEnabled()) {
- filterAndLog(FQCN, Level.ERROR, format, new Object[] {arg1, arg2}, null);
+ filterAndLog(FQCN, Level.ERROR, format, new Object[] { arg1, arg2 }, null);
}
}
public void error(String format, Object[] argArray) {
if (isErrorEnabled()) {
- filterAndLog(FQCN, Level.ERROR, format, new Object[] {argArray}, null);
+ filterAndLog(FQCN, Level.ERROR, format, new Object[] { argArray }, null);
}
}
@@ -493,21 +494,22 @@
public void error(Marker marker, String format, Object arg) {
if (isErrorEnabled()) {
- filterAndLog(FQCN, Level.ERROR, marker, format, new Object[] {arg}, null);
+ filterAndLog(FQCN, Level.ERROR, marker, format, new Object[] { arg },
+ null);
}
}
public void error(Marker marker, String format, Object arg1, Object arg2) {
if (isErrorEnabled()) {
filterAndLog(FQCN, Level.ERROR, marker, format,
- new Object[] {arg1, arg2}, null);
+ new Object[] { arg1, arg2 }, null);
}
}
public void error(Marker marker, String format, Object[] argArray) {
if (isErrorEnabled()) {
- filterAndLog(FQCN, Level.ERROR, marker, format, new Object[] {argArray},
- null);
+ filterAndLog(FQCN, Level.ERROR, marker, format,
+ new Object[] { argArray }, null);
}
}
@@ -525,19 +527,19 @@
public void info(String format, Object arg) {
if (isInfoEnabled()) {
- filterAndLog(FQCN, Level.INFO, format, new Object[] {arg}, null);
+ filterAndLog(FQCN, Level.INFO, format, new Object[] { arg }, null);
}
}
public void info(String format, Object arg1, Object arg2) {
if (isInfoEnabled()) {
- filterAndLog(FQCN, Level.INFO, format, new Object[] {arg1, arg2}, null);
+ filterAndLog(FQCN, Level.INFO, format, new Object[] { arg1, arg2 }, null);
}
}
public void info(String format, Object[] argArray) {
if (isInfoEnabled()) {
- filterAndLog(FQCN, Level.INFO, format, new Object[] {argArray}, null);
+ filterAndLog(FQCN, Level.INFO, format, new Object[] { argArray }, null);
}
}
@@ -555,20 +557,20 @@
public void info(Marker marker, String format, Object arg) {
if (isInfoEnabled()) {
- filterAndLog(FQCN, Level.INFO, marker, format, new Object[] {arg}, null);
+ filterAndLog(FQCN, Level.INFO, marker, format, new Object[] { arg }, null);
}
}
public void info(Marker marker, String format, Object arg1, Object arg2) {
if (isInfoEnabled()) {
- filterAndLog(FQCN, Level.INFO, marker, format, new Object[] {arg1, arg2},
- null);
+ filterAndLog(FQCN, Level.INFO, marker, format,
+ new Object[] { arg1, arg2 }, null);
}
}
public void info(Marker marker, String format, Object[] argArray) {
if (isInfoEnabled()) {
- filterAndLog(FQCN, Level.INFO, marker, format, new Object[] {argArray},
+ filterAndLog(FQCN, Level.INFO, marker, format, new Object[] { argArray },
null);
}
}
@@ -610,9 +612,9 @@
public boolean isWarnEnabled(Marker marker) {
return isWarnEnabled();
}
-
+
public boolean isEnabledFor(Level level) {
- return (effectiveLevelInt <= level.levelInt);
+ return (effectiveLevelInt <= level.levelInt);
}
public void warn(String msg) {
@@ -629,19 +631,19 @@
public void warn(String format, Object arg) {
if (isWarnEnabled()) {
- filterAndLog(FQCN, Level.WARN, format, new Object[] {arg}, null);
+ filterAndLog(FQCN, Level.WARN, format, new Object[] { arg }, null);
}
}
public void warn(String format, Object arg1, Object arg2) {
if (isWarnEnabled()) {
- filterAndLog(FQCN, Level.WARN, format, new Object[] {arg1, arg2}, null);
+ filterAndLog(FQCN, Level.WARN, format, new Object[] { arg1, arg2 }, null);
}
}
public void warn(String format, Object[] argArray) {
if (effectiveLevelInt <= Level.WARN_INT) {
- filterAndLog(FQCN, Level.WARN, format, new Object[] {argArray}, null);
+ filterAndLog(FQCN, Level.WARN, format, new Object[] { argArray }, null);
}
}
@@ -653,21 +655,21 @@
public void warn(Marker marker, String format, Object arg) {
if (isWarnEnabled()) {
- filterAndLog(FQCN, Level.WARN, marker, format, new Object[] {arg}, null);
+ filterAndLog(FQCN, Level.WARN, marker, format, new Object[] { arg }, null);
}
}
public void warn(Marker marker, String format, Object[] argArray) {
if (isWarnEnabled()) {
- filterAndLog(FQCN, Level.WARN, marker, format, new Object[] {argArray},
+ filterAndLog(FQCN, Level.WARN, marker, format, new Object[] { argArray },
null);
}
}
public void warn(Marker marker, String format, Object arg1, Object arg2) {
if (isWarnEnabled()) {
- filterAndLog(FQCN, Level.WARN, marker, format, new Object[] {arg1, arg2},
- null);
+ filterAndLog(FQCN, Level.WARN, marker, format,
+ new Object[] { arg1, arg2 }, null);
}
}
@@ -691,18 +693,18 @@
/**
* Return the context for this logger.
+ *
* @return
*/
- public LoggerContext getLoggerContext() {
- return loggerContext;
- }
-
-
- public LoggerRemoteView getLoggerRemoteView() {
- return loggerRemoteView;
- }
-
- void buildRemoteView() {
- this.loggerRemoteView = new LoggerRemoteView(name, loggerContext);
- }
+ public LoggerContext getLoggerContext() {
+ return loggerContext;
+ }
+
+ public LoggerRemoteView getLoggerRemoteView() {
+ return loggerRemoteView;
+ }
+
+ void buildRemoteView() {
+ this.loggerRemoteView = new LoggerRemoteView(name, loggerContext);
+ }
}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/LoggerStatusPrinter.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/LoggerStatusPrinter.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/LoggerStatusPrinter.java Wed Oct 18 16:22:03 2006
@@ -1,3 +1,13 @@
+/**
+ * Logback: the reliable, fast and flexible logging library for Java.
+ *
+ * Copyright (C) 1999-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+
package ch.qos.logback.classic.util;
import org.slf4j.LoggerFactory;
@@ -7,14 +17,13 @@
import ch.qos.logback.core.status.StatusManager;
import ch.qos.logback.core.util.StatusPrinter;
-
public class LoggerStatusPrinter {
-
- public static void printStatusInDefaultContext() {
- Logger logger = (Logger)LoggerFactory.getLogger(LoggerStatusPrinter.class);
- LoggerContext lc = logger.getLoggerContext();
- StatusManager sm = lc.getStatusManager();
+
+ public static void printStatusInDefaultContext() {
+ Logger logger = (Logger) LoggerFactory.getLogger(LoggerStatusPrinter.class);
+ LoggerContext lc = logger.getLoggerContext();
+ StatusManager sm = lc.getStatusManager();
StatusPrinter.print(sm);
- }
-
+ }
+
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java Wed Oct 18 16:22:03 2006
@@ -1,13 +1,12 @@
/**
- * Logback: the generic, reliable, fast and flexible logging framework.
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
*
- * Copyright (C) 1999-2006, QOS.ch
+ * Copyright (C) 2000-2006, QOS.ch
*
* This library is free software, you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation.
*/
-
package ch.qos.logback.core.joran;
import java.io.File;
@@ -19,13 +18,13 @@
import org.xml.sax.InputSource;
+import ch.qos.logback.core.joran.event.SaxEvent;
+import ch.qos.logback.core.joran.event.SaxEventRecorder;
import ch.qos.logback.core.joran.spi.EventPlayer;
import ch.qos.logback.core.joran.spi.ExecutionContext;
import ch.qos.logback.core.joran.spi.Interpreter;
import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.joran.spi.RuleStore;
-import ch.qos.logback.core.joran.spi.SaxEvent;
-import ch.qos.logback.core.joran.spi.SaxEventRecorder;
import ch.qos.logback.core.joran.spi.SimpleRuleStore;
import ch.qos.logback.core.spi.ContextAwareBase;
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/JoranConfiguratorBase.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/JoranConfiguratorBase.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/JoranConfiguratorBase.java Wed Oct 18 16:22:03 2006
@@ -1,7 +1,7 @@
/**
- * Logback: the generic, reliable, fast and flexible logging framework.
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
*
- * Copyright (C) 1999-2006, QOS.ch
+ * Copyright (C) 2000-2006, QOS.ch
*
* This library is free software, you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/Action.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/Action.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/Action.java Wed Oct 18 16:22:03 2006
@@ -1,12 +1,13 @@
/**
- * LOGBack: the generic, reliable, fast and flexible logging framework.
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
*
- * Copyright (C) 1999-2006, QOS.ch
+ * Copyright (C) 2000-2006, QOS.ch
*
* This library is free software, you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation.
*/
+
package ch.qos.logback.core.joran.action;
Copied: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/BodyEvent.java (from r706, /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/BodyEvent.java)
==============================================================================
--- /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/BodyEvent.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/BodyEvent.java Wed Oct 18 16:22:03 2006
@@ -1,7 +1,17 @@
-package ch.qos.logback.core.joran.spi;
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
+ *
+ * Copyright (C) 2000-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+package ch.qos.logback.core.joran.event;
import org.xml.sax.Locator;
+
public class BodyEvent extends SaxEvent {
private String text;
Copied: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/EndEvent.java (from r706, /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EndEvent.java)
==============================================================================
--- /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EndEvent.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/EndEvent.java Wed Oct 18 16:22:03 2006
@@ -1,7 +1,17 @@
-package ch.qos.logback.core.joran.spi;
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
+ *
+ * Copyright (C) 2000-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+package ch.qos.logback.core.joran.event;
import org.xml.sax.Locator;
+
public class EndEvent extends SaxEvent {
EndEvent(String namespaceURI, String localName, String qName, Locator locator) {
Added: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/InPlayListener.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/InPlayListener.java Wed Oct 18 16:22:03 2006
@@ -0,0 +1,15 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
+ *
+ * Copyright (C) 2000-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+package ch.qos.logback.core.joran.event;
+
+
+public interface InPlayListener {
+ public void inPlay(SaxEvent event);
+}
Copied: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEvent.java (from r706, /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SaxEvent.java)
==============================================================================
--- /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SaxEvent.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEvent.java Wed Oct 18 16:22:03 2006
@@ -1,14 +1,23 @@
-package ch.qos.logback.core.joran.spi;
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
+ *
+ * Copyright (C) 2000-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+package ch.qos.logback.core.joran.event;
import org.xml.sax.Locator;
import org.xml.sax.helpers.LocatorImpl;
public class SaxEvent {
- final String namespaceURI;
- final String localName;
- final String qName;
- final Locator locator;
+ final public String namespaceURI;
+ final public String localName;
+ final public String qName;
+ final public Locator locator;
SaxEvent(String namespaceURI, String localName, String qName, Locator locator) {
this.namespaceURI = namespaceURI;
Copied: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEventRecorder.java (from r706, /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SaxEventRecorder.java)
==============================================================================
--- /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SaxEventRecorder.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEventRecorder.java Wed Oct 18 16:22:03 2006
@@ -1,4 +1,14 @@
-package ch.qos.logback.core.joran.spi;
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
+ *
+ * Copyright (C) 2000-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+
+package ch.qos.logback.core.joran.event;
import java.io.IOException;
import java.io.InputStream;
@@ -16,6 +26,8 @@
import org.xml.sax.helpers.DefaultHandler;
import ch.qos.logback.core.Context;
+import ch.qos.logback.core.joran.spi.JoranException;
+import ch.qos.logback.core.joran.spi.Pattern;
import ch.qos.logback.core.spi.ContextAware;
import ch.qos.logback.core.spi.ContextAwareImpl;
import ch.qos.logback.core.status.Status;
Copied: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/StartEvent.java (from r706, /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/StartEvent.java)
==============================================================================
--- /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/StartEvent.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/StartEvent.java Wed Oct 18 16:22:03 2006
@@ -1,13 +1,25 @@
-package ch.qos.logback.core.joran.spi;
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
+ *
+ * Copyright (C) 2000-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+
+package ch.qos.logback.core.joran.event;
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
import org.xml.sax.helpers.AttributesImpl;
+import ch.qos.logback.core.joran.spi.Pattern;
+
public class StartEvent extends SaxEvent {
- final Attributes attributes;
- final Pattern pattern;
+ final public Attributes attributes;
+ final public Pattern pattern;
StartEvent(Pattern pattern, String namespaceURI, String localName, String qName,
Attributes attributes, Locator locator) {
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ActionException.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ActionException.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ActionException.java Wed Oct 18 16:22:03 2006
@@ -1,7 +1,7 @@
/**
- * LOGBack: the generic, reliable, fast and flexible logging framework.
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
*
- * Copyright (C) 1999-2006, QOS.ch
+ * Copyright (C) 2000-2006, QOS.ch
*
* This library is free software, you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java Wed Oct 18 16:22:03 2006
@@ -1,7 +1,21 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
+ *
+ * Copyright (C) 2000-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
package ch.qos.logback.core.joran.spi;
import java.util.List;
+import ch.qos.logback.core.joran.event.BodyEvent;
+import ch.qos.logback.core.joran.event.EndEvent;
+import ch.qos.logback.core.joran.event.SaxEvent;
+import ch.qos.logback.core.joran.event.StartEvent;
+
public class EventPlayer {
final Interpreter interpreter;
@@ -11,16 +25,24 @@
}
public void play(List<SaxEvent> seList) {
+
for(SaxEvent se : seList) {
if(se instanceof StartEvent) {
+ // invoke fireInPlay before startElement processing
+ interpreter.getExecutionContext().fireInPlay(se);
interpreter.startElement((StartEvent) se);
}
if(se instanceof BodyEvent) {
+ // invoke fireInPlay before characters processing
+ interpreter.getExecutionContext().fireInPlay(se);
interpreter.characters((BodyEvent) se);
}
if(se instanceof EndEvent) {
interpreter.endElement((EndEvent) se);
+ // invoke fireInPlay after endElement processing
+ interpreter.getExecutionContext().fireInPlay(se);
}
+
}
}
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ExecutionContext.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ExecutionContext.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ExecutionContext.java Wed Oct 18 16:22:03 2006
@@ -1,7 +1,7 @@
/**
- * LOGBack: the generic, reliable, fast and flexible logging framework.
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
*
- * Copyright (C) 1999-2006, QOS.ch
+ * Copyright (C) 2000-2006, QOS.ch
*
* This library is free software, you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -9,8 +9,10 @@
*/
package ch.qos.logback.core.joran.spi;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Stack;
@@ -18,6 +20,8 @@
import org.xml.sax.Locator;
import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.event.InPlayListener;
+import ch.qos.logback.core.joran.event.SaxEvent;
import ch.qos.logback.core.spi.ContextAwareBase;
import ch.qos.logback.core.status.ErrorStatus;
import ch.qos.logback.core.status.InfoStatus;
@@ -38,7 +42,8 @@
Map<String, Object> objectMap;
Properties substitutionProperties;
Interpreter joranInterpreter;
-
+ final List<InPlayListener> listenerList = new ArrayList<InPlayListener>();
+
public ExecutionContext(Interpreter joranInterpreter) {
this.joranInterpreter = joranInterpreter;
objectStack = new Stack<Object> ();
@@ -165,4 +170,22 @@
}
return OptionHelper.substVars(value, substitutionProperties);
}
+
+ public void addInPlayListener(InPlayListener ipl) {
+ if(listenerList.contains(ipl)) {
+ System.out.println("InPlayListener "+ipl+" has been already registered");
+ } else {
+ listenerList.add(ipl);
+ }
+ }
+
+ public boolean removeInPlayListener(InPlayListener ipl) {
+ return listenerList.remove(ipl);
+ }
+
+ void fireInPlay(SaxEvent event) {
+ for(InPlayListener ipl: listenerList) {
+ ipl.inPlay(event);
+ }
+ }
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java Wed Oct 18 16:22:03 2006
@@ -1,13 +1,12 @@
/**
- * LOGBack: the generic, reliable, fast and flexible logging framework.
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
*
- * Copyright (C) 1999-2006, QOS.ch
+ * Copyright (C) 2000-2006, QOS.ch
*
* This library is free software, you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation.
*/
-
package ch.qos.logback.core.joran.spi;
import java.util.ArrayList;
@@ -21,6 +20,9 @@
import ch.qos.logback.core.joran.action.Action;
import ch.qos.logback.core.joran.action.ImplicitAction;
+import ch.qos.logback.core.joran.event.BodyEvent;
+import ch.qos.logback.core.joran.event.EndEvent;
+import ch.qos.logback.core.joran.event.StartEvent;
/**
* <id>Interpreter</id> is Joran's main driving class. It extends SAX
@@ -57,9 +59,10 @@
*/
public class Interpreter {
private static List EMPTY_LIST = new Vector(0);
- private RuleStore ruleStore;
- private ExecutionContext ec;
- private ArrayList<ImplicitAction> implicitActions;
+
+ final private RuleStore ruleStore;
+ final private ExecutionContext ec;
+ final private ArrayList<ImplicitAction> implicitActions;
Pattern pattern;
Locator locator;
@@ -321,10 +324,4 @@
public RuleStore getRuleStore() {
return ruleStore;
}
-
- public void setRuleStore(RuleStore ruleStore) {
- this.ruleStore = ruleStore;
- }
-
-
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/AllTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/AllTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/AllTest.java Wed Oct 18 16:22:03 2006
@@ -1,3 +1,12 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
+ *
+ * Copyright (C) 2000-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
package ch.qos.logback.core;
import junit.framework.Test;
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java Wed Oct 18 16:22:03 2006
@@ -1,13 +1,12 @@
/**
- * Logback: the generic, reliable, fast and flexible logging framework.
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
*
- * Copyright (C) 1999-2006, QOS.ch
+ * Copyright (C) 2000-2006, QOS.ch
*
* This library is free software, you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation.
*/
-
package ch.qos.logback.core.joran;
import junit.framework.Test;
@@ -19,8 +18,8 @@
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(SkippingInInterpreterTest.class);
- suite.addTestSuite(EventRecorderTest.class);
suite.addTestSuite(TrivialcConfiguratorTest.class);
+ suite.addTest(ch.qos.logback.core.joran.event.PackageTest.suite());
suite.addTest(ch.qos.logback.core.joran.spi.PackageTest.suite());
return suite;
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java Wed Oct 18 16:22:03 2006
@@ -1,5 +1,5 @@
/**
- * LOGBack: the generic, reliable, fast and flexible logging framework.
+ * Logback: the generic, reliable, fast and flexible logging framework.
*
* Copyright (C) 1999-2006, QOS.ch
*
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialConfigurator.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialConfigurator.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialConfigurator.java Wed Oct 18 16:22:03 2006
@@ -1,3 +1,12 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework.
+ *
+ * Copyright (C) 1999-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
package ch.qos.logback.core.joran;
import java.util.HashMap;
@@ -11,7 +20,7 @@
HashMap<Pattern, Action> rulesMap;
- TrivialConfigurator(HashMap<Pattern, Action> rules) {
+ public TrivialConfigurator(HashMap<Pattern, Action> rules) {
this.rulesMap = rules;
}
Copied: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/EventRecorderTest.java (from r706, /logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/EventRecorderTest.java)
==============================================================================
--- /logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/EventRecorderTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/EventRecorderTest.java Wed Oct 18 16:22:03 2006
@@ -1,13 +1,13 @@
/**
- * Logback: the generic, reliable, fast and flexible logging framework.
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
*
- * Copyright (C) 1999-2006, QOS.ch
+ * Copyright (C) 2000-2006, QOS.ch
*
* This library is free software, you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation.
*/
-package ch.qos.logback.core.joran;
+package ch.qos.logback.core.joran.event;
import java.io.FileInputStream;
import java.util.List;
@@ -23,10 +23,10 @@
import ch.qos.logback.core.Context;
import ch.qos.logback.core.ContextBase;
-import ch.qos.logback.core.joran.spi.BodyEvent;
-import ch.qos.logback.core.joran.spi.SaxEvent;
-import ch.qos.logback.core.joran.spi.SaxEventRecorder;
-import ch.qos.logback.core.joran.spi.StartEvent;
+import ch.qos.logback.core.joran.event.BodyEvent;
+import ch.qos.logback.core.joran.event.SaxEvent;
+import ch.qos.logback.core.joran.event.SaxEventRecorder;
+import ch.qos.logback.core.joran.event.StartEvent;
import ch.qos.logback.core.status.Status;
import ch.qos.logback.core.status.StatusManager;
import ch.qos.logback.core.util.Constants;
Added: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java Wed Oct 18 16:22:03 2006
@@ -0,0 +1,43 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
+ *
+ * Copyright (C) 2000-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+package ch.qos.logback.core.joran.event;
+
+import java.util.HashMap;
+
+import junit.framework.TestCase;
+import ch.qos.logback.core.Context;
+import ch.qos.logback.core.ContextBase;
+import ch.qos.logback.core.joran.TrivialConfigurator;
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.spi.JoranException;
+import ch.qos.logback.core.joran.spi.Pattern;
+import ch.qos.logback.core.util.Constants;
+
+public class InPlayFireTest extends TestCase {
+
+ Context context = new ContextBase();
+ HashMap<Pattern, Action> rulesMap = new HashMap<Pattern, Action>();
+
+ public void testBasic() throws JoranException {
+ ListenAction listenAction = new ListenAction();
+
+ rulesMap.put(new Pattern("fire"), listenAction);
+ TrivialConfigurator gc = new TrivialConfigurator(rulesMap);
+
+ gc.setContext(context);
+ gc.doConfigure(Constants.TEST_DIR_PREFIX + "input/joran/fire1.xml");
+
+ assertEquals(3, listenAction.getSeList().size());
+ assertTrue(listenAction.getSeList().get(0) instanceof StartEvent);
+ assertTrue(listenAction.getSeList().get(1) instanceof BodyEvent);
+ assertTrue(listenAction.getSeList().get(2) instanceof EndEvent);
+
+ }
+}
Added: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/ListenAction.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/ListenAction.java Wed Oct 18 16:22:03 2006
@@ -0,0 +1,46 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
+ *
+ * Copyright (C) 2000-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+
+package ch.qos.logback.core.joran.event;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.xml.sax.Attributes;
+
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.spi.ActionException;
+import ch.qos.logback.core.joran.spi.ExecutionContext;
+
+public class ListenAction extends Action implements InPlayListener {
+
+ List<SaxEvent> seList = new ArrayList<SaxEvent>();
+
+ @Override
+ public void begin(ExecutionContext ec, String name, Attributes attributes)
+ throws ActionException {
+ ec.addInPlayListener(this);
+ }
+
+ @Override
+ public void end(ExecutionContext ec, String name) throws ActionException {
+ ec.removeInPlayListener(this);
+
+ }
+
+ public void inPlay(SaxEvent event) {
+ seList.add(event);
+ }
+
+ public List<SaxEvent> getSeList() {
+ return seList;
+ }
+
+}
Added: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/PackageTest.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/PackageTest.java Wed Oct 18 16:22:03 2006
@@ -0,0 +1,24 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework for Java.
+ *
+ * Copyright (C) 2000-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+package ch.qos.logback.core.joran.event;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class PackageTest extends TestCase {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ suite.addTestSuite(EventRecorderTest.class);
+ suite.addTestSuite(InPlayFireTest.class);
+ return suite;
+ }
+}
1
0

svn commit: r708 - in logback/trunk/logback-core/src: main/java/ch/qos/logback/core/joran/spi test/java/ch/qos/logback/core test/java/ch/qos/logback/core/joran test/java/ch/qos/logback/core/joran/action
by noreply.ceki@qos.ch 18 Oct '06
by noreply.ceki@qos.ch 18 Oct '06
18 Oct '06
Author: ceki
Date: Wed Oct 18 12:33:40 2006
New Revision: 708
Modified:
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/AllTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialConfigurator.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialcConfiguratorTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/HelloAction.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/TouchAction.java
Log:
Interpreter no longer extends DefaultHandler. This change ensures that project as a whole
stops accessing Interpreter directly and always goes through a Configurator which
goes about its business of configuring in two steps, a event registration step and a replay
(and interpret) step.
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java Wed Oct 18 12:33:40 2006
@@ -18,9 +18,6 @@
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.helpers.DefaultHandler;
import ch.qos.logback.core.joran.action.Action;
import ch.qos.logback.core.joran.action.ImplicitAction;
@@ -58,7 +55,7 @@
* @author Ceki Gülcuü
*
*/
-public class Interpreter extends DefaultHandler {
+public class Interpreter {
private static List EMPTY_LIST = new Vector(0);
private RuleStore ruleStore;
private ExecutionContext ec;
@@ -102,7 +99,7 @@
startElement(se.namespaceURI, se.localName, se.qName, se.attributes);
}
- public void startElement(String namespaceURI, String localName, String qName,
+ private void startElement(String namespaceURI, String localName, String qName,
Attributes atts) {
String tagName = getTagName(localName, qName);
@@ -146,7 +143,7 @@
endElement(endEvent.namespaceURI, endEvent.localName, endEvent.qName);
}
- public void endElement(String namespaceURI, String localName, String qName) {
+ private void endElement(String namespaceURI, String localName, String qName) {
List applicableActionList = (List) actionListStack.pop();
// System.out.println("endElement ["+getTagName(localName, qName)+"]");
@@ -270,7 +267,7 @@
}
}
- void callBodyAction(List applicableActionList, String body) {
+ private void callBodyAction(List applicableActionList, String body) {
if (applicableActionList == null) {
return;
}
@@ -287,7 +284,7 @@
}
}
- void callEndAction(List applicableActionList, String tagName) {
+ private void callEndAction(List applicableActionList, String tagName) {
if (applicableActionList == null) {
return;
}
@@ -329,95 +326,5 @@
this.ruleStore = ruleStore;
}
- // /**
- // * Call the finish methods for all actions. Unfortunately, the endDocument
- // * method is not called in case of errors in the XML document, which
- // * makes endDocument() pretty damn useless.
- // */
- // public void endDocument() {
- // Set arrayListSet = ruleStore.getActionSet();
- // Iterator iterator = arrayListSet.iterator();
- // while(iterator.hasNext()) {
- // ArrayList al = (ArrayList) iterator.next();
- // for(int i = 0; i < al.size(); i++) {
- // Action a = (Action) al.get(i);
- // a.endDocument(ec);
- // }
- // }
- // }
- public void error(SAXParseException spe) throws SAXException {
- ec.addError("Parsing error", this, spe);
- ec.addError("Parsing problem on line " + spe.getLineNumber()
- + " and column " + spe.getColumnNumber(), this, spe);
- }
-
- public void fatalError(SAXParseException spe) throws SAXException {
- ec.addError("Parsing fatal error", this, spe);
- ec.addError("Parsing problem on line " + spe.getLineNumber()
- + " and column " + spe.getColumnNumber(), this, spe);
- }
-
- public void warning(SAXParseException spe) throws SAXException {
- ec.addWarn("Parsing warning", this, spe);
- ec.addWarn("Parsing problem on line " + spe.getLineNumber()
- + " and column " + spe.getColumnNumber(), this, spe);
- }
-
- public void endPrefixMapping(java.lang.String prefix) {
- }
-
- public void ignorableWhitespace(char[] ch, int start, int length) {
- }
-
- public void processingInstruction(java.lang.String target,
- java.lang.String data) {
- }
-
- public void skippedEntity(java.lang.String name) {
- }
-
- public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) {
- }
-
- // public EntityResolver getEntityResolver() {
- // return entityResolver;
- // }
- //
- // public void setEntityResolver(EntityResolver entityResolver) {
- // this.entityResolver = entityResolver;
- // }
-
- /**
- * If a specific entityResolver is set for this Interpreter instance, then we
- * use it to resolve entities. Otherwise, we use the default implementation
- * offered by the super class.
- *
- * <p>
- * Due to inexplicable voodoo, the original resolveEntity method in
- * org.xml.sax.helpers.DefaultHandler declares throwing an IOException,
- * whereas the org.xml.sax.helpers.DefaultHandler class included in JDK 1.4
- * masks this exception.
- *
- * <p>
- * In order to compile under JDK 1.4, we are forced to mask the IOException as
- * well. Since its signatures varies, we cannot call our super class'
- * resolveEntity method. We are forced to implement the default behavior
- * ourselves, which in this case, is just returning null.
- *
- */
- // public InputSource resolveEntity(String publicId, String systemId) throws
- // SAXException {
- // if(entityResolver == null) {
- // // the default implementation is to return null
- // return null;
- // } else {
- // try {
- // return entityResolver.resolveEntity(publicId, systemId);
- // } catch(IOException ioe) {
- // // fall back to the default "implementation"
- // return null;
- // }
- // }
- // }
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/AllTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/AllTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/AllTest.java Wed Oct 18 12:33:40 2006
@@ -1,14 +1,12 @@
package ch.qos.logback.core;
-
-
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
public class AllTest extends TestCase {
- public static Test suite() {
+ public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(ch.qos.logback.core.util.PackageTest.suite());
suite.addTest(ch.qos.logback.core.pattern.AllTest.suite());
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java Wed Oct 18 12:33:40 2006
@@ -9,22 +9,22 @@
*/
package ch.qos.logback.core.joran;
+import java.util.HashMap;
+
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import ch.qos.logback.core.Context;
import ch.qos.logback.core.ContextBase;
+import ch.qos.logback.core.joran.action.Action;
import ch.qos.logback.core.joran.action.BadBeginAction;
import ch.qos.logback.core.joran.action.BadEndAction;
import ch.qos.logback.core.joran.action.HelloAction;
import ch.qos.logback.core.joran.action.TouchAction;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
-import ch.qos.logback.core.joran.spi.Interpreter;
import ch.qos.logback.core.joran.spi.Pattern;
-import ch.qos.logback.core.joran.spi.RuleStore;
-import ch.qos.logback.core.joran.spi.SimpleRuleStore;
import ch.qos.logback.core.util.Constants;
@@ -36,8 +36,12 @@
*/
public class SkippingInInterpreterTest extends TestCase {
+ HashMap<Pattern, Action> rulesMap = new HashMap<Pattern, Action>();
+ Context context = new ContextBase();
+
public SkippingInInterpreterTest(String name) {
super(name);
+
}
protected void setUp() throws Exception {
@@ -63,22 +67,21 @@
* @throws Exception
*/
public void testChildrenSkipping() throws Exception {
- RuleStore rs = new SimpleRuleStore(new ContextBase());
- rs.addRule(new Pattern("test"), new NOPAction());
- rs.addRule(new Pattern("test/badBegin"), new BadBeginAction());
- rs.addRule(new Pattern("test/badBegin/touch"), new TouchAction());
- rs.addRule(new Pattern("test/hello"), new HelloAction());
-
- Interpreter jp = new Interpreter(rs);
- ExecutionContext ec = jp.getExecutionContext();
- ec.setContext(new ContextBase());
-
- SAXParser saxParser = createParser();
- saxParser.parse("file:" + Constants.TEST_DIR_PREFIX + "input/joran/exception1.xml", jp);
- String str = (String) ec.getObjectMap().get("hello");
+
+ rulesMap.put(new Pattern("test"), new NOPAction());
+ rulesMap.put(new Pattern("test/badBegin"), new BadBeginAction());
+ rulesMap.put(new Pattern("test/badBegin/touch"), new TouchAction());
+ rulesMap.put(new Pattern("test/hello"), new HelloAction());
+
+ TrivialConfigurator tc = new TrivialConfigurator(rulesMap);
+ tc.setContext(context);
+
+ tc.doConfigure(Constants.TEST_DIR_PREFIX + "input/joran/exception1.xml");
+
+ String str = context.getProperty("hello");
assertEquals("Hello John Doe.", str);
- Object i = ec.getObjectMap().get(TouchAction.KEY);
+ Object i = (String) context.getObject(TouchAction.KEY);
assertNull(i);
}
@@ -90,43 +93,38 @@
*/
public void testSkipSiblings() throws Exception {
- RuleStore rs = new SimpleRuleStore(new ContextBase());
- rs.addRule(new Pattern("test"), new NOPAction());
- rs.addRule(new Pattern("test/badEnd"), new BadEndAction());
- rs.addRule(new Pattern("test/badEnd/touch"), new TouchAction());
- rs.addRule(new Pattern("test/hello"), new HelloAction());
-
- Interpreter jp = new Interpreter(rs);
- ExecutionContext ec = jp.getExecutionContext();
- ec.setContext(new ContextBase());
+ rulesMap.put(new Pattern("test"), new NOPAction());
+ rulesMap.put(new Pattern("test/badEnd"), new BadEndAction());
+ rulesMap.put(new Pattern("test/badEnd/touch"), new TouchAction());
+ rulesMap.put(new Pattern("test/hello"), new HelloAction());
+
+ TrivialConfigurator tc = new TrivialConfigurator(rulesMap);
+ tc.setContext(context);
- SAXParser saxParser = createParser();
- saxParser.parse("file:" + Constants.TEST_DIR_PREFIX + "input/joran/badEnd1.xml", jp);
+ tc.doConfigure(Constants.TEST_DIR_PREFIX + "input/joran/badEnd1.xml");
+
- String str = (String) ec.getObjectMap().get("hello");
+ String str = context.getProperty("hello");
assertNull(str);
- Integer i = (Integer) ec.getObjectMap().get(TouchAction.KEY);
+ Integer i = (Integer) context.getObject(TouchAction.KEY);
assertEquals(2, i.intValue());
}
public void testSkipSiblings2() throws Exception {
- RuleStore rs = new SimpleRuleStore(new ContextBase());
- rs.addRule(new Pattern("test"), new NOPAction());
- rs.addRule(new Pattern("test/isolate/badEnd"), new BadEndAction());
- rs.addRule(new Pattern("*/touch"), new TouchAction());
- rs.addRule(new Pattern("test/hello"), new HelloAction());
-
- Interpreter jp = new Interpreter(rs);
- ExecutionContext ec = jp.getExecutionContext();
- ec.setContext(new ContextBase());
+ rulesMap.put(new Pattern("test"), new NOPAction());
+ rulesMap.put(new Pattern("test/isolate/badEnd"), new BadEndAction());
+ rulesMap.put(new Pattern("*/touch"), new TouchAction());
+ rulesMap.put(new Pattern("test/hello"), new HelloAction());
+
+ TrivialConfigurator tc = new TrivialConfigurator(rulesMap);
+ tc.setContext(context);
- SAXParser saxParser = createParser();
- saxParser.parse("file:" + Constants.TEST_DIR_PREFIX + "input/joran/badEnd2.xml", jp);
+ tc.doConfigure(Constants.TEST_DIR_PREFIX + "input/joran/badEnd2.xml");
- String str = (String) ec.getObjectMap().get("hello");
+ String str = context.getProperty("hello");
assertEquals("Hello John Doe.", str);
- Integer i = (Integer) ec.getObjectMap().get(TouchAction.KEY);
+ Integer i = (Integer) context.getObject(TouchAction.KEY);
assertEquals(1, i.intValue());
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialConfigurator.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialConfigurator.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialConfigurator.java Wed Oct 18 12:33:40 2006
@@ -1,20 +1,30 @@
package ch.qos.logback.core.joran;
-import ch.qos.logback.core.joran.action.IncAction;
+import java.util.HashMap;
+
+import ch.qos.logback.core.joran.action.Action;
import ch.qos.logback.core.joran.spi.Interpreter;
import ch.qos.logback.core.joran.spi.Pattern;
import ch.qos.logback.core.joran.spi.RuleStore;
public class TrivialConfigurator extends GenericConfigurator {
+ HashMap<Pattern, Action> rulesMap;
+
+ TrivialConfigurator(HashMap<Pattern, Action> rules) {
+ this.rulesMap = rules;
+ }
+
@Override
protected void addImplicitRules(Interpreter interpreter) {
}
@Override
protected void addInstanceRules(RuleStore rs) {
- rs.addRule(new Pattern("x/inc"), new IncAction());
-
+ for(Pattern pattern : rulesMap.keySet()) {
+ Action action = rulesMap.get(pattern);
+ rs.addRule(pattern, action);
+ }
}
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialcConfiguratorTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialcConfiguratorTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialcConfiguratorTest.java Wed Oct 18 12:33:40 2006
@@ -1,9 +1,13 @@
package ch.qos.logback.core.joran;
+import java.util.HashMap;
+
import junit.framework.TestCase;
import ch.qos.logback.core.Context;
import ch.qos.logback.core.ContextBase;
+import ch.qos.logback.core.joran.action.Action;
import ch.qos.logback.core.joran.action.IncAction;
+import ch.qos.logback.core.joran.spi.Pattern;
import ch.qos.logback.core.util.Constants;
public class TrivialcConfiguratorTest extends TestCase {
@@ -24,7 +28,11 @@
public void doTest(String filename) throws Exception {
- TrivialConfigurator gc = new TrivialConfigurator();
+ HashMap<Pattern, Action> rulesMap = new HashMap<Pattern, Action>();
+ rulesMap.put(new Pattern("x/inc"), new IncAction());
+
+ TrivialConfigurator gc = new TrivialConfigurator(rulesMap);
+
gc.setContext(context);
gc.doConfigure(Constants.TEST_DIR_PREFIX
+ "input/joran/"+ filename);
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/HelloAction.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/HelloAction.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/HelloAction.java Wed Oct 18 12:33:40 2006
@@ -27,7 +27,7 @@
*/
public void begin(ExecutionContext ec, String name, Attributes attributes) {
String str = "Hello "+attributes.getValue("name")+".";
- ec.getObjectMap().put("hello", str);
+ ec.getContext().setProperty("hello", str);
}
/**
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/TouchAction.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/TouchAction.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/TouchAction.java Wed Oct 18 12:33:40 2006
@@ -29,11 +29,11 @@
*
*/
public void begin(ExecutionContext ec, String name, Attributes attributes) {
- Integer i = (Integer) ec.getObjectMap().get(KEY);
+ Integer i = (Integer) ec.getContext().getObject(KEY);
if(i == null) {
- ec.getObjectMap().put(KEY, new Integer(1));
+ ec.getContext().putObject(KEY, new Integer(1));
} else {
- ec.getObjectMap().put(KEY, new Integer(i.intValue()+1));
+ ec.getContext().putObject(KEY, new Integer(i.intValue()+1));
}
}
1
0

svn commit: r707 - in logback/trunk: logback-access/src/main/java/ch/qos/logback/access/jetty logback-site/src/site/xdocTemplates/manual
by noreply.seb@qos.ch 18 Oct '06
by noreply.seb@qos.ch 18 Oct '06
18 Oct '06
Author: seb
Date: Wed Oct 18 12:22:35 2006
New Revision: 707
Modified:
logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java
logback/trunk/logback-site/src/site/xdocTemplates/manual/layouts.xml
Log:
Work in progress
- adding examples to conversion words.
Modified: logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java
==============================================================================
--- logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java (original)
+++ logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java Wed Oct 18 12:22:35 2006
@@ -114,6 +114,7 @@
AccessEvent accessEvent = new AccessEvent(jettyRequest, jettyResponse,
adapter);
// TODO better exception handling
+ //check filter decision see AppenderBase
aai.appendLoopOnAppenders(accessEvent);
}
Modified: logback/trunk/logback-site/src/site/xdocTemplates/manual/layouts.xml
==============================================================================
--- logback/trunk/logback-site/src/site/xdocTemplates/manual/layouts.xml (original)
+++ logback/trunk/logback-site/src/site/xdocTemplates/manual/layouts.xml Wed Oct 18 12:22:35 2006
@@ -18,25 +18,27 @@
<table>
<tr>
<td valign="top" align="top">
- <a rel="license"
- href="http://creativecommons.org/licenses/by-nc-nd/2.5/">
- <img alt="Creative Commons License" border="0"
- valign="top" align="top"
- src="http://creativecommons.org/images/public/somerights20.png" />
- </a>
+ <a rel="license"
+ href="http://creativecommons.org/licenses/by-nc-sa/2.5/">
+ <img alt="Creative Commons License"
+ style="border-width: 0"
+ src="http://creativecommons.org/images/public/somerights20.png" />
+ </a>
</td>
<td>
<p>Copyright © 2000-2006, QOS.ch</p>
<p>
+ <!--Creative Commons License-->
This work is licensed under a
<a rel="license"
- href="http://creativecommons.org/licenses/by-nc-nd/2.5/">
+ href="http://creativecommons.org/licenses/by-nc-sa/2.5/">
Creative Commons
- Attribution-Noncommercial-No Derivative
- Works 2.5 License
+ Attribution-NonCommercial-ShareAlike 2.5
+ License
</a>
.
+ <!--/Creative Commons License-->
</p>
</td>
</tr>
@@ -124,8 +126,8 @@
called conversion specifiers. You are free to insert any
literal text within the conversion pattern. Each conversion
specifier starts with a percent sign (%) and is followed by
- optional format modifiers and a conversion character. The
- conversion character controls the type of data to use, e.g.
+ optional format modifiers and a conversion word. The
+ conversion word controls the type of data to use, e.g.
logger name, level, date, thread name. The format modifiers
control such things as field width, padding, and left or
right justification. The following is a simple example.
@@ -175,9 +177,15 @@
justified to a width of five characters. Format specifiers
will be explained in a short moment.
</p>
- <p>The recognized conversion characters and words are</p>
+ <p>
+ Some conversion words can handle options. These are informations
+ added to the conversion word between braces. A sample conversion
+ word with options could be <em>%word{option}</em>. The options that
+ are specific to a conversion word will be explained shortly, along with
+ the conversion word's definition.
+ </p>
<table border="1" CELLPADDING="8">
- <th>Conversion Character or Word</th>
+ <th>Conversion Word</th>
<th>Effect</th>
<tr>
@@ -188,27 +196,51 @@
<td>
<p>
Used to output the logger of the logging event.
- The logger conversion specifier can be
- optionally followed by
- <em>precision specifier</em>
- , that is a decimal constant in brackets.
- </p>
- <p>
- If a precision specifier is given, then only the
- corresponding number of right most components of
- the logger name will be printed. By default the
- logger name is printed in full.
- </p>
- <p>
- For example, for the category name "a.b.c" the
- pattern
- <b>%logger{2}</b>
- will output "b.c". See more examples of name
- abbreviations further down this document.
</p>
+ <p>
+ The logger name conversion word can take an
+ integer as a first option. This will use
+ logback's abbreviation mechanism to display a
+ shorter logger name, without loosing it's
+ meaning.
+ </p>
+
+ <p>The next table should clear things up.</p>
+
+ <table BORDER="1" CELLPADDING="8">
+
+ <tr>
+ <th>Conversion Pattern</th>
+ <th>Logger name</th>
+ <th>Result</th>
+ </tr>
+
+ <tr>
+ <td>%logger{10}</td>
+ <td>mainPackage.sub.sample.Bar</td>
+ <td>m.s.s.Bar</td>
+ </tr>
+
+ <tr>
+ <td>%logger{15}</td>
+ <td>mainPackage.sub.sample.Bar</td>
+ <td>m.s.sample.Bar</td>
+ </tr>
+
+ <tr>
+ <td>%logger{16}</td>
+ <td>mainPackage.sub.sample.Bar</td>
+ <td>m.sub.sample.Bar</td>
+ </tr>
+
+ <tr>
+ <td>%logger{26}</td>
+ <td>mainPackage.sub.sample.Bar</td>
+ <td>mainPackage.sub.sample.Bar</td>
+ </tr>
+ </table>
</td>
</tr>
-
<tr>
<td align="center">
<b>C / class</b>
@@ -217,24 +249,17 @@
<td>
<p>
Used to output the fully qualified class name of
- the caller issuing the logging request. This
- conversion specifier can be optionally followed
- by
- <em>precision specifier</em>
- , that is a decimal constant in brackets.
- </p>
- <p>
- If a precision specifier is given, then only the
- corresponding number of right most components of
- the class name will be printed. By default the
- class name is output in fully qualified form.
- </p>
- <p>
- For example, for the class name
- "ch.logback.xyz.SomeClass", the pattern
- <b>%class{1}</b>
- will output "SomeClass". See more examples of
- name abbreviations further down this document.
+ the caller issuing the logging request.
+ </p>
+ <p>
+ Just like the previous conversion word, this
+ word can take an interger as it's first option
+ and use logback's abbreviation mechanisme to
+ shorten its output.
+ </p>
+ <p>
+ By default the class name is output in fully
+ qualified form.
</p>
<p>
<b>WARNING</b>
@@ -254,13 +279,15 @@
Used to output the date of the logging event.
The date conversion specifier may be followed by
a set of braces containing a date and time
- pattern strings following <code>java.text.SimpleDateFormat</code>,
+ pattern strings used by
+ <code>java.text.SimpleDateFormat</code>
+ .
<em>ABSOLUTE</em>
,
<em>DATE</em>
or
<em>ISO8601</em>
- .
+ can also be used.
</p>
<p>
For example,
@@ -314,18 +341,29 @@
number between parentheses.
</p>
<p>
+ A integer can be added to the
+ <em>caller</em>
+ conversion specifier's options to configure the depth of
+ the information to be displayed.
+ </p>
+ <p>For example, <em>%caller{2}</em> would display the following excerpt:</p>
+
+<div class="source">0 [main] DEBUG - logging statement Caller+0 \
+at mainPackage.sub.sample.Bar.sampleMethodName(Bar.java:22)
+Caller+1 at mainPackage.sub.sample.Bar.createLoggingRequest(Bar.java:17)</div>
+ <p>And <em>%caller{3}</em> would display this other excerpt:</p>
+<div class="source">16 [main] DEBUG - logging statement Caller+0 \
+at mainPackage.sub.sample.Bar.sampleMethodName(Bar.java:22)
+Caller+1 at mainPackage.sub.sample.Bar.createLoggingRequest(Bar.java:17)
+Caller+2 at mainPackage.ConfigTester.main(ConfigTester.java:38)</div>
+
+ <p>
The location information can be very useful.
However, it's generation is
<em>extremely</em>
slow. It's use should be avoided unless
execution speed is not an issue.
</p>
- <p>
- A precision specifier can be appended to the
- <em>caller</em>
- conversion specifier to configure the depth of
- the information to be displayed.
- </p>
</td>
</tr>
@@ -389,7 +427,7 @@
character or characters.
</p>
<p>
- This conversion character offers practically the
+ This conversion word offers practically the
same performance as using non-portable line
separator strings such as "\n", or "\r\n". Thus,
it is the preferred way of specifying a line
@@ -447,7 +485,7 @@
<p>
The
<b>X</b>
- conversion character can be followed by the key
+ conversion word can be followed by the key
for the map placed between braces, as in
<b>%X{clientNumber}</b>
where
@@ -475,7 +513,7 @@
</tr>
<tr>
<td align="center">
- <b>throwable</b>
+ <b>ex / throwable</b>
</td>
<td>
@@ -623,47 +661,7 @@
.
</p>
<p>However, there is much more to it than that.</p>
- <p>
- The logger name conversion specifier can take an integer as
- a first option. This will use logback's abbreviation
- mechanism to display a shorter logger name, without loosing
- it's meaning.
- </p>
-
- <p>The next table should clear things up.</p>
-
- <table BORDER="1" CELLPADDING="8">
-
- <tr>
- <th>Conversion Pattern</th>
- <th>Logger name</th>
- <th>Result</th>
- </tr>
-
- <tr>
- <td>%logger{10}</td>
- <td>mainPackage.sub.sample.Bar</td>
- <td>m.s.s.Bar</td>
- </tr>
-
- <tr>
- <td>%logger{15}</td>
- <td>mainPackage.sub.sample.Bar</td>
- <td>m.s.sample.Bar</td>
- </tr>
-
- <tr>
- <td>%logger{16}</td>
- <td>mainPackage.sub.sample.Bar</td>
- <td>m.sub.sample.Bar</td>
- </tr>
- <tr>
- <td>%logger{26}</td>
- <td>mainPackage.sub.sample.Bar</td>
- <td>mainPackage.sub.sample.Bar</td>
- </tr>
- </table>
<h4>Evaluators</h4>
<p>
@@ -966,7 +964,7 @@
<code>PatternLayout</code>.</p>
<table border="1" CELLPADDING="8">
- <th align="center">Conversion Character or Word</th>
+ <th align="center">Conversion Word</th>
<th align="center">Effect</th>
<tr>
1
0

svn commit: r706 - in logback/trunk/logback-core/src/test: input/joran java/ch/qos/logback/core/util
by noreply.ceki@qos.ch 17 Oct '06
by noreply.ceki@qos.ch 17 Oct '06
17 Oct '06
Author: ceki
Date: Tue Oct 17 23:39:30 2006
New Revision: 706
Added:
logback/trunk/logback-core/src/test/input/joran/attributesEvent.xml
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/StatusPrinterTest.java
Log:
adding missing files
Added: logback/trunk/logback-core/src/test/input/joran/attributesEvent.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/input/joran/attributesEvent.xml Tue Oct 17 23:39:30 2006
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<inc increment="1"/>
Added: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/StatusPrinterTest.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/StatusPrinterTest.java Tue Oct 17 23:39:30 2006
@@ -0,0 +1,56 @@
+package ch.qos.logback.core.util;
+
+import junit.framework.TestCase;
+import ch.qos.logback.core.Context;
+import ch.qos.logback.core.ContextBase;
+import ch.qos.logback.core.status.ErrorStatus;
+import ch.qos.logback.core.status.InfoStatus;
+import ch.qos.logback.core.status.Status;
+import ch.qos.logback.core.status.WarnStatus;
+
+public class StatusPrinterTest extends TestCase {
+
+ public StatusPrinterTest(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testBasic() {
+ Context context = new ContextBase();
+ context.getStatusManager().add(new InfoStatus("test", this));
+ StatusPrinter.print(context);
+ }
+
+ public void testNested() {
+ Status s0 = new ErrorStatus("test0", this);
+ Status s1 = new InfoStatus("test1", this);
+ Status s11 = new InfoStatus("test11", this);
+ Status s12 = new InfoStatus("test12", this);
+ s1.add(s11);
+ s1.add(s12);
+
+ Status s2 = new InfoStatus("test2", this);
+ Status s21 = new InfoStatus("test21", this);
+ Status s211 = new WarnStatus("test211", this);
+
+ Status s22 = new InfoStatus("test22", this);
+ s2.add(s21);
+ s2.add(s22);
+ s21.add(s211);
+
+
+ Context context = new ContextBase();
+ context.getStatusManager().add(s0);
+ context.getStatusManager().add(s1);
+ context.getStatusManager().add(s2);
+ StatusPrinter.print(context);
+ }
+
+}
1
0