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

svn commit: r745 - logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay
by noreply.seb@qos.ch 23 Oct '06
by noreply.seb@qos.ch 23 Oct '06
23 Oct '06
Author: seb
Date: Mon Oct 23 20:02:10 2006
New Revision: 745
Modified:
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
Log:
added a setter for eventlist
Modified: 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/FruitFactory.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitFactory.java Mon Oct 23 20:02:10 2006
@@ -11,7 +11,7 @@
static int count = 0;
- List<SaxEvent> eventList;
+ private List<SaxEvent> eventList;
Fruit fruit;
public void setFruit(Fruit fruit) {
@@ -51,4 +51,8 @@
return retValue.toString();
}
+ public void setEventList(List<SaxEvent> eventList) {
+ this.eventList = eventList;
+ }
+
}
Modified: 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/FruitFactoryAction.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitFactoryAction.java Mon Oct 23 20:02:10 2006
@@ -39,7 +39,7 @@
if(o instanceof FruitShell) {
FruitShell fs = (FruitShell) o;
FruitFactory fruitFactory = new FruitFactory();
- fruitFactory.eventList = new ArrayList<SaxEvent>(seList);
+ fruitFactory.setEventList(new ArrayList<SaxEvent>(seList));
fs.setFruitFactory(fruitFactory);
}
}
1
0

svn commit: r744 - in logback/trunk: . logback-classic logback-core
by noreply.seb@qos.ch 23 Oct '06
by noreply.seb@qos.ch 23 Oct '06
23 Oct '06
Author: seb
Date: Mon Oct 23 19:58:17 2006
New Revision: 744
Modified:
logback/trunk/logback-classic/pom.xml
logback/trunk/logback-core/pom.xml
logback/trunk/pom.xml
Log:
dependency corrections
Modified: logback/trunk/logback-classic/pom.xml
==============================================================================
--- logback/trunk/logback-classic/pom.xml (original)
+++ logback/trunk/logback-classic/pom.xml Mon Oct 23 19:58:17 2006
@@ -56,6 +56,13 @@
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>janino</groupId>
+ <artifactId>janino</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
Modified: logback/trunk/logback-core/pom.xml
==============================================================================
--- logback/trunk/logback-core/pom.xml (original)
+++ logback/trunk/logback-core/pom.xml Mon Oct 23 19:58:17 2006
@@ -34,11 +34,12 @@
<dependency>
<groupId>janino</groupId>
<artifactId>janino</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
- <scope>compile</scope>
+ <scope>provided</scope>
</dependency>
</dependencies>
Modified: logback/trunk/pom.xml
==============================================================================
--- logback/trunk/pom.xml (original)
+++ logback/trunk/pom.xml Mon Oct 23 19:58:17 2006
@@ -49,14 +49,11 @@
<classifier>tests</classifier>
</dependency>
- <!-- Core Module Dependencies -->
<dependency>
<groupId>janino</groupId>
<artifactId>janino</artifactId>
<version>2.4.3</version>
</dependency>
-
- <!-- Classic Module Dependencies -->
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
@@ -77,26 +74,16 @@
<artifactId>hsqldb</artifactId>
<version>1.8.0.5</version>
</dependency>
-
- <!-- Access Module Dependencies -->
<dependency>
<groupId>tomcat</groupId>
<artifactId>catalina</artifactId>
<version>5.5.12</version>
</dependency>
-
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<version>6.0.0</version>
- </dependency>
-
- <dependency>
- <groupId>com.caucho</groupId>
- <artifactId>resin</artifactId>
- <version>3.0.9</version>
- </dependency>
-
+ </dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>servlet-api-2.5</artifactId>
1
0

svn commit: r743 - logback/trunk/logback-access/src/main/java/ch/qos/logback/access/joran/action
by noreply.ceki@qos.ch 23 Oct '06
by noreply.ceki@qos.ch 23 Oct '06
23 Oct '06
Author: ceki
Date: Mon Oct 23 19:02:39 2006
New Revision: 743
Modified:
logback/trunk/logback-access/src/main/java/ch/qos/logback/access/joran/action/ConfigurationAction.java
Log:
- renaming of ch.qos.logback.core.joran.spi.ExecutionContext as InterpretationContext
Modified: logback/trunk/logback-access/src/main/java/ch/qos/logback/access/joran/action/ConfigurationAction.java
==============================================================================
--- logback/trunk/logback-access/src/main/java/ch/qos/logback/access/joran/action/ConfigurationAction.java (original)
+++ logback/trunk/logback-access/src/main/java/ch/qos/logback/access/joran/action/ConfigurationAction.java Mon Oct 23 19:02:39 2006
@@ -13,7 +13,7 @@
import org.xml.sax.Attributes;
import ch.qos.logback.core.joran.action.Action;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
@@ -21,14 +21,14 @@
static final String INTERNAL_DEBUG_ATTR = "debug";
boolean attachment = false;
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
//String debugAttrib = attributes.getValue(INTERNAL_DEBUG_ATTR);
// the context is appender attachable, so it is pushed on top of the stack
ec.pushObject(getContext());
}
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
ec.popObject();
}
}
1
0

svn commit: r742 - in logback/trunk/logback-classic/src: main/java/ch/qos/logback/classic main/java/ch/qos/logback/classic/joran/action main/java/ch/qos/logback/classic/pattern main/java/ch/qos/logback/classic/spi test/java/ch/qos/logback/classic/net
by noreply.ceki@qos.ch 23 Oct '06
by noreply.ceki@qos.ch 23 Oct '06
23 Oct '06
Author: ceki
Date: Mon Oct 23 18:54:25 2006
New Revision: 742
Modified:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LevelAction.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoggerAction.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/RootLoggerAction.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/DateConverter.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextRemoteView.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerRemoteView.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/LoggingEventSerializationTest.java
Log:
- LoggingEventSerialization test now passes
- renaming of ch.qos.logback.core.joran.spi.ExecutionContext as InterpretationContext
- minor lincesing related corrections
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java Mon Oct 23 18:54:25 2006
@@ -61,6 +61,12 @@
logger.buildRemoteView();
}
}
+
+ @Override
+ public void setProperty(String key, String val) {
+ super.setProperty(key, val);
+ syncRemoteView();
+ }
@Override
public void setName(String name) {
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java Mon Oct 23 18:54:25 2006
@@ -13,7 +13,7 @@
import org.xml.sax.Attributes;
import ch.qos.logback.core.joran.action.Action;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
@@ -21,7 +21,7 @@
static final String INTERNAL_DEBUG_ATTR = "debug";
boolean attachment = false;
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
String debugAttrib = attributes.getValue(INTERNAL_DEBUG_ATTR);
if (
@@ -36,7 +36,7 @@
}
}
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
if (attachment) {
addInfo("End of configuration.");
//LoggerContext loggerContext = (LoggerContext) context;
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LevelAction.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LevelAction.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LevelAction.java Mon Oct 23 18:54:25 2006
@@ -15,7 +15,7 @@
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.core.joran.action.Action;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
public class LevelAction extends Action {
@@ -29,7 +29,7 @@
boolean inError = false;
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
Object o = ec.peekObject();
if (!(o instanceof Logger)) {
@@ -55,9 +55,9 @@
addInfo(loggerName + " level set to " + l.getLevel());
}
- public void finish(ExecutionContext ec) {
+ public void finish(InterpretationContext ec) {
}
- public void end(ExecutionContext ec, String e) {
+ public void end(InterpretationContext ec, String e) {
}
}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoggerAction.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoggerAction.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoggerAction.java Mon Oct 23 18:54:25 2006
@@ -17,7 +17,7 @@
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.joran.action.Action;
import ch.qos.logback.core.joran.action.ActionConst;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.util.OptionHelper;
@@ -25,7 +25,7 @@
public class LoggerAction extends Action {
boolean inError = false;
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
// Let us forget about previous errors (in this object)
inError = false;
@@ -63,12 +63,12 @@
ec.pushObject(l);
}
- public void end(ExecutionContext ec, String e) {
+ public void end(InterpretationContext ec, String e) {
if (!inError) {
ec.popObject();
}
}
- public void finish(ExecutionContext ec) {
+ public void finish(InterpretationContext ec) {
}
}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/RootLoggerAction.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/RootLoggerAction.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/RootLoggerAction.java Mon Oct 23 18:54:25 2006
@@ -15,7 +15,7 @@
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.joran.action.Action;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
public class RootLoggerAction extends Action {
static final String NAME_ATTR = "name";
@@ -27,7 +27,7 @@
Logger root;
boolean inError = false;
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
inError = false;
//logger.debug("In begin method");
@@ -38,7 +38,7 @@
ec.pushObject(root);
}
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
//logger.debug("end() called.");
if (inError) {
@@ -57,6 +57,6 @@
}
}
- public void finish(ExecutionContext ec) {
+ public void finish(InterpretationContext ec) {
}
}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/DateConverter.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/DateConverter.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/DateConverter.java Mon Oct 23 18:54:25 2006
@@ -1,11 +1,11 @@
/**
- * LOGBack: the reliable, fast and flexible logging library for Java.
- *
+ * 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.
+ *
+ * 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.pattern;
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextRemoteView.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextRemoteView.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextRemoteView.java Mon Oct 23 18:54:25 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.classic.spi;
import java.io.Serializable;
@@ -6,43 +15,44 @@
import ch.qos.logback.classic.LoggerContext;
/**
- * LoggerContextRemoteView offers a restricted view of LoggerContext intended to be
- * exposed by LoggingEvent. This restricted view is optimised for serialisation.
+ * LoggerContextRemoteView offers a restricted view of LoggerContext intended to
+ * be exposed by LoggingEvent. This restricted view is optimised for
+ * serialisation.
*
- * Some of the LoggerContext or Logger attributes should not survive
- * serialization, e.g appenders, level values etc, as these attributes may
- * have other values on the remote platform. LoggerContextRemoteView class exposes
- * the minimal (relevant) attributes to remote host, instead of having to deal with
- * an incomplete LoggerContext with many null references.
+ * Some of the LoggerContext or Logger attributes should not survive
+ * serialization, e.g appenders, level values etc, as these attributes may have
+ * other values on the remote platform. LoggerContextRemoteView class exposes
+ * the minimal (relevant) attributes to remote host, instead of having to deal
+ * with an incomplete LoggerContext with many null references.
*
* @author Ceki Gülcü
* @author Sébastien Pennec
*/
public class LoggerContextRemoteView implements Serializable {
-
- private static final long serialVersionUID = 5488023392483144387L;
+ private static final long serialVersionUID = 5488023392483144387L;
- final String name;
- final Map<String, String> propertyMap;
+ final String name;
+ final Map<String, String> propertyMap;
-
- public LoggerContextRemoteView(LoggerContext lc) {
- //this(lc.getName(), lc.getPropertyMap());
- this.name = lc.getName();
- this.propertyMap = lc.getPropertyMap();
- }
-
-// public LoggerContextRemoteView(String name, Map<String, String> propertyMap) {
-// this.name = name;
-// this.propertyMap = propertyMap;
-// }
-
- public String getName() {
- return name;
- }
- public Map<String, String> getPropertyMap() {
- return propertyMap;
- }
+ public LoggerContextRemoteView(LoggerContext lc) {
+ // this(lc.getName(), lc.getPropertyMap());
+ this.name = lc.getName();
+ this.propertyMap = lc.getPropertyMap();
+ }
+
+ // public LoggerContextRemoteView(String name, Map<String, String>
+ // propertyMap) {
+ // this.name = name;
+ // this.propertyMap = propertyMap;
+ // }
+
+ public String getName() {
+ return name;
+ }
+
+ public Map<String, String> getPropertyMap() {
+ return propertyMap;
+ }
}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerRemoteView.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerRemoteView.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerRemoteView.java Mon Oct 23 18:54:25 2006
@@ -1,5 +1,5 @@
/**
- * Logback: the reliable, generic, fast and flexible logging framework.
+ * Logback: the generic, reliable, fast and flexible logging framework.
*
* Copyright (C) 1999-2006, QOS.ch
*
@@ -25,26 +25,23 @@
*/
public class LoggerRemoteView implements Serializable {
+ private static final long serialVersionUID = 5028223666108713696L;
- private static final long serialVersionUID = 5028223666108713696L;
-
- final LoggerContextRemoteView loggerContextView;
- final String name;
-
- public LoggerRemoteView(String name, LoggerContext lc) {
- this.name = name;
- assert lc.getLoggerContextRemoteView() != null;
- loggerContextView = lc.getLoggerContextRemoteView();
- }
-
-
- public LoggerContextRemoteView getLoggerContextView() {
- return loggerContextView;
- }
-
- public String getName() {
- return name;
- }
+ final LoggerContextRemoteView loggerContextView;
+ final String name;
+ public LoggerRemoteView(String name, LoggerContext lc) {
+ this.name = name;
+ assert lc.getLoggerContextRemoteView() != null;
+ loggerContextView = lc.getLoggerContextRemoteView();
+ }
+
+ public LoggerContextRemoteView getLoggerContextView() {
+ return loggerContextView;
+ }
+
+ public String getName() {
+ return name;
+ }
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/LoggingEventSerializationTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/LoggingEventSerializationTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/LoggingEventSerializationTest.java Mon Oct 23 18:54:25 2006
@@ -79,6 +79,7 @@
assertNotNull(loggerContextRemoteView);
assertEquals("testContext", loggerContextRemoteView.getName());
Map<String, String> props = loggerContextRemoteView.getPropertyMap();
+ assertNotNull(props);
assertEquals("testValue", props.get("testKey"));
}
1
0
Author: ceki
Date: Mon Oct 23 18:45:52 2006
New Revision: 741
Added:
logback/trunk/logback-core/examples/src/joran/SimpleConfigurator.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/InterpretationContext.java
- copied, changed from r734, /logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ExecutionContext.java
logback/trunk/logback-core/src/test/input/joran/fruitWithSubst.xml
Removed:
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ExecutionContext.java
Modified:
logback/trunk/logback-core/examples/src/joran/calculator/AddAction.java
logback/trunk/logback-core/examples/src/joran/calculator/Calculator1.java
logback/trunk/logback-core/examples/src/joran/calculator/Calculator2.java
logback/trunk/logback-core/examples/src/joran/calculator/ComputationAction1.java
logback/trunk/logback-core/examples/src/joran/calculator/ComputationAction2.java
logback/trunk/logback-core/examples/src/joran/calculator/LiteralAction.java
logback/trunk/logback-core/examples/src/joran/calculator/MultiplyAction.java
logback/trunk/logback-core/examples/src/joran/helloWorld/HelloWorld.java
logback/trunk/logback-core/examples/src/joran/helloWorld/HelloWorldAction.java
logback/trunk/logback-core/examples/src/joran/implicit/NOPAction.java
logback/trunk/logback-core/examples/src/joran/implicit/PrintMe.java
logback/trunk/logback-core/examples/src/joran/implicit/PrintMeImplicitAction.java
logback/trunk/logback-core/examples/src/joran/newRule/NewRuleCalculator.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/Context.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/ContextBase.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/AbstractEventEvaluatorAction.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/AbstractLayoutAction.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/action/AppenderAction.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/AppenderRefAction.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/ConversionRuleAction.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/ImplicitAction.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/MatcherAction.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/NOPAction.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedComponentIA.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/action/NewRuleAction.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/ParamAction.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/PropertyAction.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/RepositoryPropertyAction.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/SubstitutionPropertyAction.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEventRecorder.java
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/rolling/TimeBasedRollingPolicy.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/spi/ContextAwareBase.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/spi/ContextAwareImpl.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.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/joran/action/BadBeginAction.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/BadEndAction.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/IncAction.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/StackCounterAction.java
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/event/ListenAction.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/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/FruitShellAction.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/SimpleStoreTest.java
Log:
- Added support for variable substitition from the context (in Joran)
- Other small changes
- minor license related corrections
Added: logback/trunk/logback-core/examples/src/joran/SimpleConfigurator.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/examples/src/joran/SimpleConfigurator.java Mon Oct 23 18:45:52 2006
@@ -0,0 +1,55 @@
+/**
+ * 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 joran;
+
+import java.util.List;
+import java.util.Map;
+
+import ch.qos.logback.core.joran.GenericConfigurator;
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.action.ImplicitAction;
+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 {
+
+ final Map<Pattern, Action> ruleMap;
+ final List<ImplicitAction> iaList;
+
+ public SimpleConfigurator(Map<Pattern, Action> ruleMap) {
+ this(ruleMap, null);
+ }
+
+ public SimpleConfigurator(Map<Pattern, Action> ruleMap, List<ImplicitAction> iaList) {
+ this.ruleMap = ruleMap;
+ this.iaList = iaList;
+ }
+
+ @Override
+ protected void addInstanceRules(RuleStore rs) {
+
+ for (Pattern pattern : ruleMap.keySet()) {
+ Action action = ruleMap.get(pattern);
+ rs.addRule(pattern, action);
+ }
+ }
+
+ @Override
+ protected void addImplicitRules(Interpreter interpreter) {
+ if(iaList == null) {
+ return;
+ }
+ for (ImplicitAction ia : iaList) {
+ interpreter.addImplicitAction(ia);
+ }
+ }
+
+}
Modified: logback/trunk/logback-core/examples/src/joran/calculator/AddAction.java
==============================================================================
--- logback/trunk/logback-core/examples/src/joran/calculator/AddAction.java (original)
+++ logback/trunk/logback-core/examples/src/joran/calculator/AddAction.java Mon Oct 23 18:45:52 2006
@@ -15,7 +15,7 @@
import org.xml.sax.Attributes;
import ch.qos.logback.core.joran.action.Action;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
import java.util.EmptyStackException;
@@ -28,7 +28,7 @@
*/
public class AddAction extends Action {
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
int first = fetchInteger(ec);
int second = fetchInteger(ec);
// Push the result of the addition for the following actions.
@@ -39,7 +39,7 @@
* Pop the Integer object at the top of the stack.
* This code illustrates usage of Joran's error handling paradigm.
*/
- int fetchInteger(ExecutionContext ec) {
+ int fetchInteger(InterpretationContext ec) {
int result = 0;
try {
@@ -62,7 +62,7 @@
return result;
}
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
// Nothing to do here.
// In general, the end() method of actions associated with elements
// having no children do not need to perform any processing in their
Modified: logback/trunk/logback-core/examples/src/joran/calculator/Calculator1.java
==============================================================================
--- logback/trunk/logback-core/examples/src/joran/calculator/Calculator1.java (original)
+++ logback/trunk/logback-core/examples/src/joran/calculator/Calculator1.java Mon Oct 23 18:45:52 2006
@@ -10,72 +10,59 @@
package joran.calculator;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
+import java.util.HashMap;
+import java.util.Map;
+import joran.SimpleConfigurator;
import ch.qos.logback.core.Context;
import ch.qos.logback.core.ContextBase;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
-import ch.qos.logback.core.joran.spi.Interpreter;
+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.joran.spi.RuleStore;
-import ch.qos.logback.core.joran.spi.SimpleRuleStore;
import ch.qos.logback.core.util.StatusPrinter;
-
/**
* This examples illustrates collaboration between multiple actions through the
* common execution context stack.
*
- * The first and only argument of this application must be the path to
- * the XML file to interpret. There are sample XML files in the
- * <em>examples/src/joran/calculator/</em> directory.
- *
+ * The first and only argument of this application must be the path to the XML
+ * file to interpret. There are sample XML files in the
+ * <em>examples/src/joran/calculator/</em> directory.
+ *
* For example,
- *
-<pre>
- java joran.calculator.Calculator1 examples/src/joran/calculator/calculator1.xml
-</pre>
- *
+ *
+ * <pre>
+ * java joran.calculator.Calculator1 examples/src/joran/calculator/calculator1.xml
+ * </pre>
+ *
* Please refer to the comments in the source code for more information.
*
* @author Ceki Güulcü
*/
public class Calculator1 {
-
-
+
public static void main(String[] args) throws Exception {
Context context = new ContextBase();
-
- // Create a simple rule store where pattern and action associations will
- // be kept. This is a basic requirement before invoking a Joran Interpreter.
- RuleStore ruleStore = new SimpleRuleStore(context);
- // Associate "/computation" pattern with ComputationAction1
- ruleStore.addRule(new Pattern("/computation"), new ComputationAction1());
+ Map<Pattern, Action> ruleMap = new HashMap<Pattern, Action>();
+
+ // Associate "/computation" pattern with ComputationAction1
+ ruleMap.put(new Pattern("/computation"), new ComputationAction1());
// Other associations
- ruleStore.addRule(new Pattern("/computation/literal"), new LiteralAction());
- ruleStore.addRule(new Pattern("/computation/add"), new AddAction());
- ruleStore.addRule(new Pattern("/computation/multiply"), new MultiplyAction());
-
- // Create a new Joran Interpreter and hand it our simple rule store.
- Interpreter ji = new Interpreter(ruleStore);
- // set the context for the interpreter's execution context
- ExecutionContext ec = ji.getExecutionContext();
- ec.setContext(context);
-
-
- // Create a SAX parser
- SAXParserFactory spf = SAXParserFactory.newInstance();
- SAXParser saxParser = spf.newSAXParser();
-
- // Parse the file given as the application's first argument and
- // set the SAX ContentHandler to the Joran Interpreter we just created.
- saxParser.parse(args[0], ji);
-
- // The file has been parsed and interpreted. We now print any errors that
- // might have occured.
- StatusPrinter.print(context);
+ ruleMap.put(new Pattern("/computation/literal"), new LiteralAction());
+ ruleMap.put(new Pattern("/computation/add"), new AddAction());
+ ruleMap.put(new Pattern("/computation/multiply"), new MultiplyAction());
+
+ SimpleConfigurator simpleConfigurator = new SimpleConfigurator(ruleMap);
+ // link the configurator with its context
+ simpleConfigurator.setContext(context);
+
+ try {
+ simpleConfigurator.doConfigure(args[0]);
+ } catch (JoranException e) {
+ // Print any errors that might have occured.
+ StatusPrinter.print(context);
+ }
}
}
Modified: logback/trunk/logback-core/examples/src/joran/calculator/Calculator2.java
==============================================================================
--- logback/trunk/logback-core/examples/src/joran/calculator/Calculator2.java (original)
+++ logback/trunk/logback-core/examples/src/joran/calculator/Calculator2.java Mon Oct 23 18:45:52 2006
@@ -9,16 +9,15 @@
*/
package joran.calculator;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
+import java.util.HashMap;
+import java.util.Map;
+import joran.SimpleConfigurator;
import ch.qos.logback.core.Context;
import ch.qos.logback.core.ContextBase;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
-import ch.qos.logback.core.joran.spi.Interpreter;
+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.joran.spi.RuleStore;
-import ch.qos.logback.core.joran.spi.SimpleRuleStore;
import ch.qos.logback.core.util.StatusPrinter;
@@ -35,36 +34,27 @@
*/
public class Calculator2 {
public static void main(String[] args) throws Exception {
- Context context = new ContextBase();
- RuleStore ruleStore = new SimpleRuleStore(context);
+ Map<Pattern, Action> ruleMap = new HashMap<Pattern, Action>();
// Note the wild card character '*', in the paterns, signifying any level
// of nesting.
- ruleStore.addRule(new Pattern("*/computation"), new ComputationAction2());
-
- ruleStore.addRule(new Pattern("*/computation/literal"), new LiteralAction());
- ruleStore.addRule(new Pattern("*/computation/add"), new AddAction());
- ruleStore.addRule(new Pattern("*/computation/multiply"), new MultiplyAction());
-
- // Create a new Joran Interpreter and hand it our simple rule store.
- Interpreter ji = new Interpreter(ruleStore);
- // set the context for the interpreter's execution context
- ExecutionContext ec = ji.getExecutionContext();
- ec.setContext(context);
+ ruleMap.put(new Pattern("*/computation"), new ComputationAction2());
+ ruleMap.put(new Pattern("*/computation/literal"), new LiteralAction());
+ ruleMap.put(new Pattern("*/computation/add"), new AddAction());
+ ruleMap.put(new Pattern("*/computation/multiply"), new MultiplyAction());
- // Create a SAX parser
- SAXParserFactory spf = SAXParserFactory.newInstance();
- SAXParser saxParser = spf.newSAXParser();
-
- // Parse the file given as the application's first argument and
- // set the SAX ContentHandler to the Joran Interpreter we just created.
- saxParser.parse(args[0], ji);
-
- // The file has been parsed and interpreted. We now print any errors that
- // might have occured.
- StatusPrinter.print(context);
-
+ Context context = new ContextBase();
+ SimpleConfigurator simpleConfigurator = new SimpleConfigurator(ruleMap);
+ // link the configurator with its context
+ simpleConfigurator.setContext(context);
+
+ try {
+ simpleConfigurator.doConfigure(args[0]);
+ } catch (JoranException e) {
+ // Print any errors that might have occured.
+ StatusPrinter.print(context);
+ }
}
}
Modified: logback/trunk/logback-core/examples/src/joran/calculator/ComputationAction1.java
==============================================================================
--- logback/trunk/logback-core/examples/src/joran/calculator/ComputationAction1.java (original)
+++ logback/trunk/logback-core/examples/src/joran/calculator/ComputationAction1.java Mon Oct 23 18:45:52 2006
@@ -15,7 +15,7 @@
import org.xml.sax.Attributes;
import ch.qos.logback.core.joran.action.Action;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.util.OptionHelper;
@@ -35,7 +35,7 @@
/**
* Store the value of the name attribute for future use.
*/
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
nameStr = attributes.getValue(NAME_ATR);
}
@@ -46,7 +46,7 @@
* This value will be printed on the console but only if the action is
* named. Anonymous computation will not print their result.
*/
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
if (OptionHelper.isEmpty(nameStr)) {
// nothing to do
} else {
Modified: logback/trunk/logback-core/examples/src/joran/calculator/ComputationAction2.java
==============================================================================
--- logback/trunk/logback-core/examples/src/joran/calculator/ComputationAction2.java (original)
+++ logback/trunk/logback-core/examples/src/joran/calculator/ComputationAction2.java Mon Oct 23 18:45:52 2006
@@ -15,7 +15,7 @@
import org.xml.sax.Attributes;
import ch.qos.logback.core.joran.action.Action;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.util.OptionHelper;
@@ -61,14 +61,14 @@
Stack<String> nameStrStack = new Stack<String>();
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
String nameStr = attributes.getValue(NAME_ATR);
// save nameStr value in a special stack. Note that the value is saved
// even if it is empty or null.
nameStrStack.push(nameStr);
}
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
// pop nameStr value from the special stack
String nameStr = (String) nameStrStack.pop();
Modified: logback/trunk/logback-core/examples/src/joran/calculator/LiteralAction.java
==============================================================================
--- logback/trunk/logback-core/examples/src/joran/calculator/LiteralAction.java (original)
+++ logback/trunk/logback-core/examples/src/joran/calculator/LiteralAction.java Mon Oct 23 18:45:52 2006
@@ -13,7 +13,7 @@
import org.xml.sax.Attributes;
import ch.qos.logback.core.joran.action.Action;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.util.OptionHelper;
/**
@@ -29,7 +29,7 @@
public class LiteralAction extends Action {
public static String VALUE_ATR = "value";
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
String valueStr = attributes.getValue(VALUE_ATR);
if (OptionHelper.isEmpty(valueStr)) {
@@ -47,7 +47,7 @@
}
}
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
// Nothing to do here.
// In general, the end() method of actions associated with elements
// having no children do not need to perform any processing in their
Modified: logback/trunk/logback-core/examples/src/joran/calculator/MultiplyAction.java
==============================================================================
--- logback/trunk/logback-core/examples/src/joran/calculator/MultiplyAction.java (original)
+++ logback/trunk/logback-core/examples/src/joran/calculator/MultiplyAction.java Mon Oct 23 18:45:52 2006
@@ -1,5 +1,5 @@
/**
- * Logback: the reliable, fast and flexible logging library for Java.
+ * Logback: the generic, reliable, fast and flexible logging framework.
*
* Copyright (C) 1999-2006, QOS.ch
*
@@ -14,7 +14,7 @@
import org.xml.sax.Attributes;
import ch.qos.logback.core.joran.action.Action;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
import java.util.EmptyStackException;
@@ -29,7 +29,7 @@
public class MultiplyAction extends Action {
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
int first = fetchInteger(ec);
int second = fetchInteger(ec);
ec.pushObject(new Integer(first * second));
@@ -39,7 +39,7 @@
* Pop the Integer object at the top of the stack.
* This code illustrates usage of Joran's error handling paradigm.
*/
- int fetchInteger(ExecutionContext ec) {
+ int fetchInteger(InterpretationContext ec) {
int result = 0;
try {
@@ -61,7 +61,7 @@
return result;
}
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
// Nothing to do here.
// In general, the end() method of actions associated with elements
// having no children do not need to perform any processing in their
Modified: logback/trunk/logback-core/examples/src/joran/helloWorld/HelloWorld.java
==============================================================================
--- logback/trunk/logback-core/examples/src/joran/helloWorld/HelloWorld.java (original)
+++ logback/trunk/logback-core/examples/src/joran/helloWorld/HelloWorld.java Mon Oct 23 18:45:52 2006
@@ -10,16 +10,15 @@
package joran.helloWorld;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
+import java.util.HashMap;
+import java.util.Map;
+import joran.SimpleConfigurator;
import ch.qos.logback.core.Context;
import ch.qos.logback.core.ContextBase;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
-import ch.qos.logback.core.joran.spi.Interpreter;
+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.joran.spi.RuleStore;
-import ch.qos.logback.core.joran.spi.SimpleRuleStore;
import ch.qos.logback.core.util.StatusPrinter;
@@ -40,29 +39,22 @@
*/
public class HelloWorld {
public static void main(String[] args) throws Exception {
- // Create a simple rule store where pattern and action associations will
- // be kept.
- Context context = new ContextBase();
- RuleStore ruleStore = new SimpleRuleStore(context);
+ Map<Pattern, Action> ruleMap = new HashMap<Pattern, Action>();
// Associate "hello-world" pattern with HelloWorldAction
- ruleStore.addRule(new Pattern("hello-world"), new HelloWorldAction());
+ ruleMap.put(new Pattern("hello-world"), new HelloWorldAction());
- // Create a new Joran Interpreter and hand it our simple rule store.
- Interpreter ji = new Interpreter(ruleStore);
- ExecutionContext ec = ji.getExecutionContext();
- ec.setContext(context);
-
- // Create a SAX parser
- SAXParserFactory spf = SAXParserFactory.newInstance();
- SAXParser saxParser = spf.newSAXParser();
-
- // Parse the file given as the application's first argument and
- // set the SAX ContentHandler to the Joran Interpreter we just created.
- saxParser.parse(args[0], ji);
-
- // The file has been parsed and interpreted. We now print any errors that
- // might have occured.
- StatusPrinter.print(context);
- }
+ // Joran needs to work within a context.
+ Context context = new ContextBase();
+ SimpleConfigurator simpleConfigurator = new SimpleConfigurator(ruleMap);
+ // link the configurator with its context
+ simpleConfigurator.setContext(context);
+
+ try {
+ simpleConfigurator.doConfigure(args[0]);
+ } catch (JoranException e) {
+ // Print any errors that might have occured.
+ StatusPrinter.print(context);
+ }
+ }
}
Modified: logback/trunk/logback-core/examples/src/joran/helloWorld/HelloWorldAction.java
==============================================================================
--- logback/trunk/logback-core/examples/src/joran/helloWorld/HelloWorldAction.java (original)
+++ logback/trunk/logback-core/examples/src/joran/helloWorld/HelloWorldAction.java Mon Oct 23 18:45:52 2006
@@ -15,7 +15,7 @@
import org.xml.sax.Attributes;
import ch.qos.logback.core.joran.action.Action;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
/**
@@ -26,10 +26,10 @@
* @author Ceki Gülcü
*/
public class HelloWorldAction extends Action {
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
System.out.println("Hello World");
}
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
}
}
Modified: logback/trunk/logback-core/examples/src/joran/implicit/NOPAction.java
==============================================================================
--- logback/trunk/logback-core/examples/src/joran/implicit/NOPAction.java (original)
+++ logback/trunk/logback-core/examples/src/joran/implicit/NOPAction.java Mon Oct 23 18:45:52 2006
@@ -12,7 +12,7 @@
import org.xml.sax.Attributes;
import ch.qos.logback.core.joran.action.Action;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
@@ -23,10 +23,10 @@
*/
public class NOPAction extends Action {
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
}
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
}
}
Modified: logback/trunk/logback-core/examples/src/joran/implicit/PrintMe.java
==============================================================================
--- logback/trunk/logback-core/examples/src/joran/implicit/PrintMe.java (original)
+++ logback/trunk/logback-core/examples/src/joran/implicit/PrintMe.java Mon Oct 23 18:45:52 2006
@@ -1,5 +1,5 @@
/**
- * Logback: the reliable, fast and flexible logging library for Java.
+ * Logback: the generic, reliable, fast and flexible logging framework.
*
* Copyright (C) 1999-2006, QOS.ch
*
@@ -7,20 +7,20 @@
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation.
*/
-
-
package joran.implicit;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import joran.SimpleConfigurator;
import ch.qos.logback.core.Context;
import ch.qos.logback.core.ContextBase;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
-import ch.qos.logback.core.joran.spi.Interpreter;
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.action.ImplicitAction;
+import ch.qos.logback.core.joran.spi.JoranException;
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.StatusPrinter;
@@ -39,34 +39,29 @@
public static void main(String[] args) throws Exception {
Context context = new ContextBase();
- RuleStore ruleStore = new SimpleRuleStore(context);
+ Map<Pattern, Action> ruleMap = new HashMap<Pattern, Action>();
+
// we start with the rule for the top-most (root) element
- ruleStore.addRule(new Pattern("*/foo"), new NOPAction());
+ ruleMap.put(new Pattern("*/foo"), new NOPAction());
- // Create a new Joran Interpreter and hand it our simple rule store.
- Interpreter ji = new Interpreter(ruleStore);
- // set the context for the interpreter's execution context
- ExecutionContext ec = ji.getExecutionContext();
- ec.setContext(context);
-
-
+ List<ImplicitAction> iaList = new ArrayList<ImplicitAction>();
// --------------------------+
// Add an implicit action. |
// --------------------------+
- ji.addImplicitAction(new PrintMeImplicitAction());
+ iaList.add(new PrintMeImplicitAction());
+
+ SimpleConfigurator simpleConfigurator = new SimpleConfigurator(ruleMap, iaList);
+ // link the configurator with its context
+ simpleConfigurator.setContext(context);
+
+ try {
+ simpleConfigurator.doConfigure(args[0]);
+ } catch (JoranException e) {
+ // Print any errors that might have occured.
+ StatusPrinter.print(context);
+ }
- // Create a SAX parser
- SAXParserFactory spf = SAXParserFactory.newInstance();
- SAXParser saxParser = spf.newSAXParser();
-
- // Parse the file given as the application's first argument and
- // set the SAX ContentHandler to the Joran Interpreter we just created.
- saxParser.parse(args[0], ji);
-
- // The file has been parsed and interpreted. We now print any errors that
- // might have occured.
- StatusPrinter.print(context);
}
}
Modified: logback/trunk/logback-core/examples/src/joran/implicit/PrintMeImplicitAction.java
==============================================================================
--- logback/trunk/logback-core/examples/src/joran/implicit/PrintMeImplicitAction.java (original)
+++ logback/trunk/logback-core/examples/src/joran/implicit/PrintMeImplicitAction.java Mon Oct 23 18:45:52 2006
@@ -13,7 +13,7 @@
import org.xml.sax.Attributes;
import ch.qos.logback.core.joran.action.ImplicitAction;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.joran.spi.Pattern;
@@ -28,17 +28,17 @@
public class PrintMeImplicitAction extends ImplicitAction {
public boolean isApplicable(
- Pattern pattern, Attributes attributes, ExecutionContext ec) {
+ Pattern pattern, Attributes attributes, InterpretationContext ec) {
String printmeStr = attributes.getValue("printme");
return Boolean.valueOf(printmeStr).booleanValue();
}
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
System.out.println("Element <"+name+"> asked to be printed.");
}
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
}
}
Modified: logback/trunk/logback-core/examples/src/joran/newRule/NewRuleCalculator.java
==============================================================================
--- logback/trunk/logback-core/examples/src/joran/newRule/NewRuleCalculator.java (original)
+++ logback/trunk/logback-core/examples/src/joran/newRule/NewRuleCalculator.java Mon Oct 23 18:45:52 2006
@@ -10,18 +10,17 @@
package joran.newRule;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
+import java.util.HashMap;
+import java.util.Map;
+import joran.SimpleConfigurator;
import joran.calculator.ComputationAction2;
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.NewRuleAction;
-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.Pattern;
-import ch.qos.logback.core.joran.spi.RuleStore;
-import ch.qos.logback.core.joran.spi.SimpleRuleStore;
import ch.qos.logback.core.util.StatusPrinter;
@@ -36,38 +35,31 @@
*/
public class NewRuleCalculator {
public static void main(String[] args) throws Exception {
- // As usual, we create a simple rule store.
+
Context context = new ContextBase();
- RuleStore ruleStore = new SimpleRuleStore(context);
+
+ Map<Pattern, Action> ruleMap = new HashMap<Pattern, Action>();
+
// we start with the rule for the top-most (root) element
- ruleStore.addRule(new Pattern("*/computation"), new ComputationAction2());
+ ruleMap.put(new Pattern("*/computation"), new ComputationAction2());
// Associate "/new-rule" pattern with NewRuleAction from the
// org.apache.joran.action package.
//
// We will let the XML file to teach the Joran interpreter about new rules
- ruleStore.addRule(
+ ruleMap.put(
new Pattern("/computation/new-rule"), new NewRuleAction());
- // Create a new Joran Interpreter and hand it our simple rule store.
- Interpreter ji = new Interpreter(ruleStore);
- // set the context for the interpreter's execution context
- ExecutionContext ec = ji.getExecutionContext();
- ec.setContext(context);
-
-
- // Create a SAX parser
- SAXParserFactory spf = SAXParserFactory.newInstance();
- SAXParser saxParser = spf.newSAXParser();
-
- // Parse the file given as the application's first argument and
- // set the SAX ContentHandler to the Joran Interpreter we just created.
- saxParser.parse(args[0], ji);
-
-
- // The file has been parsed and interpreted. We now print any errors that
- // might have occured.
- StatusPrinter.print(context);
- }
+ SimpleConfigurator simpleConfigurator = new SimpleConfigurator(ruleMap);
+ // link the configurator with its context
+ simpleConfigurator.setContext(context);
+
+ try {
+ simpleConfigurator.doConfigure(args[0]);
+ } catch (JoranException e) {
+ // Print any errors that might have occured.
+ StatusPrinter.print(context);
+ }
+ }
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/Context.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/Context.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/Context.java Mon Oct 23 18:45:52 2006
@@ -36,10 +36,13 @@
*/
public void putObject(String key, Object value);
- /**
- * Get the properties specific for this context.
+ /**
+ * Get all the properties for this context as a Map. Note that
+ * the returned cop might be a copy not the original. Thus, modifying
+ * the returned Map will have no effect (on the original.)
+ * @return
*/
- public Map getPropertyMap();
+ public Map<String, String> getPropertyMap();
/**
* Get the property of this context.
@@ -51,7 +54,7 @@
*/
public void setProperty(String key, String value);
-
+
/**
* LB contexts have a notion of context-specific converter maps.
* @return
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java Mon Oct 23 18:45:52 2006
@@ -16,10 +16,9 @@
import ch.qos.logback.core.spi.FilterAttachableImpl;
import ch.qos.logback.core.status.StatusManager;
-
public class ContextBase implements Context {
- private String name;
+ private String name;
StatusManager sm = new BasicStatusManager();
// TODO propertyMap should be observable so that we can be notified
// when it changes so that a new instance of propertyMap can be
@@ -28,19 +27,19 @@
Map<String, Object> objectMap = new HashMap<String, Object>();
Map<String, String> converterMap = new HashMap<String, String>();
private FilterAttachableImpl fai = new FilterAttachableImpl();
-
+
public StatusManager getStatusManager() {
return sm;
}
-
+
public Map<String, String> getPropertyMap() {
- return propertyMap;
+ return new HashMap<String, String>(propertyMap);
}
public void setProperty(String key, String val) {
this.propertyMap.put(key, val);
}
-
+
public String getProperty(String key) {
return (String) this.propertyMap.get(key);
}
@@ -52,7 +51,7 @@
public void putObject(String key, Object value) {
objectMap.put(key, value);
}
-
+
public Map<String, String> getConverterMap() {
return converterMap;
}
@@ -60,7 +59,7 @@
public void addFilter(Filter newFilter) {
fai.addFilter(newFilter);
}
-
+
public Filter getFirstFilter() {
return fai.getFirstFilter();
}
@@ -73,14 +72,14 @@
return fai.getFilterChainDecision(event);
}
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- if(this.name != null) {
- throw new IllegalStateException("Context has been already given a name");
- }
- this.name = name;
- }
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ if (this.name != null) {
+ throw new IllegalStateException("Context has been already given a name");
+ }
+ this.name = name;
+ }
}
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 Mon Oct 23 18:45:52 2006
@@ -21,7 +21,7 @@
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.InterpretationContext;
import ch.qos.logback.core.joran.spi.Interpreter;
import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.joran.spi.RuleStore;
@@ -81,8 +81,8 @@
protected void buildInterpreter() {
RuleStore rs = new SimpleRuleStore(context);
addInstanceRules(rs);
- this.interpreter = new Interpreter(rs);
- ExecutionContext ec = interpreter.getExecutionContext();
+ this.interpreter = new Interpreter(context, rs);
+ InterpretationContext ec = interpreter.getExecutionContext();
ec.setContext(context);
addImplicitRules(interpreter);
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 Mon Oct 23 18:45:52 2006
@@ -24,7 +24,7 @@
import ch.qos.logback.core.joran.action.ParamAction;
import ch.qos.logback.core.joran.action.RepositoryPropertyAction;
import ch.qos.logback.core.joran.action.SubstitutionPropertyAction;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.joran.spi.Interpreter;
import ch.qos.logback.core.joran.spi.Pattern;
import ch.qos.logback.core.joran.spi.RuleStore;
@@ -85,7 +85,7 @@
omap.put(ActionConst.FILTER_CHAIN_BAG, new HashMap());
}
- public ExecutionContext getExecutionContext() {
+ public InterpretationContext getExecutionContext() {
return interpreter.getExecutionContext();
}
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/AbstractEventEvaluatorAction.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/AbstractEventEvaluatorAction.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/AbstractEventEvaluatorAction.java Mon Oct 23 18:45:52 2006
@@ -18,7 +18,7 @@
import ch.qos.logback.core.CoreGlobal;
import ch.qos.logback.core.boolex.EventEvaluator;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.spi.LifeCycle;
import ch.qos.logback.core.util.OptionHelper;
@@ -31,7 +31,7 @@
/**
* Instantiates an evaluator of the given class and sets its name.
*/
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
// Let us forget about previous errors (in this instance)
inError = false;
evaluator = null;
@@ -94,7 +94,7 @@
* Once the children elements are also parsed, now is the time to activate
* the evaluator options.
*/
- public void end(ExecutionContext ec, String e) {
+ public void end(InterpretationContext ec, String e) {
if (inError) {
return;
}
@@ -122,6 +122,6 @@
}
}
- public void finish(ExecutionContext ec) {
+ public void finish(InterpretationContext ec) {
}
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/AbstractLayoutAction.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/AbstractLayoutAction.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/AbstractLayoutAction.java Mon Oct 23 18:45:52 2006
@@ -16,7 +16,7 @@
import ch.qos.logback.core.Appender;
import ch.qos.logback.core.Layout;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.spi.LifeCycle;
import ch.qos.logback.core.util.OptionHelper;
@@ -30,7 +30,7 @@
* Instantiates an layout of the given class and sets its name.
*
*/
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
// Let us forget about previous errors (in this object)
inError = false;
@@ -66,7 +66,7 @@
* Once the children elements are also parsed, now is the time to activate
* the appender options.
*/
- public void end(ExecutionContext ec, String e) {
+ public void end(InterpretationContext ec, String e) {
if (inError) {
return;
}
@@ -95,6 +95,6 @@
}
}
- public void finish(ExecutionContext ec) {
+ public void finish(InterpretationContext ec) {
}
}
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 Mon Oct 23 18:45:52 2006
@@ -15,7 +15,7 @@
import org.xml.sax.Locator;
import ch.qos.logback.core.joran.spi.ActionException;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.joran.spi.Interpreter;
import ch.qos.logback.core.spi.ContextAwareBase;
@@ -51,20 +51,20 @@
* the returned value is 'false', then child elements are ignored.
*/
public abstract void begin(
- ExecutionContext ec, String name, Attributes attributes) throws ActionException ;
+ InterpretationContext ec, String name, Attributes attributes) throws ActionException ;
- public void body(ExecutionContext ec, String body) throws ActionException {
+ public void body(InterpretationContext ec, String body) throws ActionException {
// NOP
}
- public abstract void end(ExecutionContext ec, String name) throws ActionException;
+ public abstract void end(InterpretationContext ec, String name) throws ActionException;
public String toString() {
return this.getClass().getName();
}
- protected int getColumnNumber(ExecutionContext ec) {
+ protected int getColumnNumber(InterpretationContext ec) {
Interpreter jp = ec.getJoranInterpreter();
Locator locator = jp.getLocator();
if (locator != null) {
@@ -73,7 +73,7 @@
return -1;
}
- protected int getLineNumber(ExecutionContext ec) {
+ protected int getLineNumber(InterpretationContext ec) {
Interpreter jp = ec.getJoranInterpreter();
Locator locator = jp.getLocator();
if (locator != null) {
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/AppenderAction.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/AppenderAction.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/AppenderAction.java Mon Oct 23 18:45:52 2006
@@ -16,7 +16,7 @@
import ch.qos.logback.core.Appender;
import ch.qos.logback.core.joran.spi.ActionException;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.spi.LifeCycle;
import ch.qos.logback.core.util.OptionHelper;
@@ -32,7 +32,7 @@
* The appender thus generated is placed in the ExecutionContext appender bag.
*/
public void begin(
- ExecutionContext ec, String localName, Attributes attributes) throws ActionException {
+ InterpretationContext ec, String localName, Attributes attributes) throws ActionException {
String className = attributes.getValue(CLASS_ATTRIBUTE);
// We are just beginning, reset variables
@@ -79,7 +79,7 @@
* Once the children elements are also parsed, now is the time to activate
* the appender options.
*/
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
if (inError) {
return;
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/AppenderRefAction.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/AppenderRefAction.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/AppenderRefAction.java Mon Oct 23 18:45:52 2006
@@ -14,7 +14,7 @@
import ch.qos.logback.core.Appender;
import ch.qos.logback.core.CoreGlobal;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.spi.AppenderAttachable;
import ch.qos.logback.core.util.OptionHelper;
@@ -24,7 +24,7 @@
public class AppenderRefAction extends Action {
boolean inError = false;
- public void begin(ExecutionContext ec, String tagName, Attributes attributes) {
+ public void begin(InterpretationContext ec, String tagName, Attributes attributes) {
// Let us forget about previous errors (in this object)
inError = false;
@@ -72,9 +72,9 @@
appenderAttachable.addAppender(appender);
}
- public void end(ExecutionContext ec, String n) {
+ public void end(InterpretationContext ec, String n) {
}
- public void finish(ExecutionContext ec) {
+ public void finish(InterpretationContext ec) {
}
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/ConversionRuleAction.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/ConversionRuleAction.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/ConversionRuleAction.java Mon Oct 23 18:45:52 2006
@@ -16,7 +16,7 @@
import org.xml.sax.Attributes;
import ch.qos.logback.core.CoreGlobal;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.util.OptionHelper;
@@ -28,7 +28,7 @@
* Instantiates an layout of the given class and sets its name.
*
*/
- public void begin(ExecutionContext ec, String localName, Attributes attributes) {
+ public void begin(InterpretationContext ec, String localName, Attributes attributes) {
// Let us forget about previous errors (in this object)
inError = false;
@@ -79,9 +79,9 @@
* Once the children elements are also parsed, now is the time to activate
* the appender options.
*/
- public void end(ExecutionContext ec, String n) {
+ public void end(InterpretationContext ec, String n) {
}
- public void finish(ExecutionContext ec) {
+ public void finish(InterpretationContext ec) {
}
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/ImplicitAction.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/ImplicitAction.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/ImplicitAction.java Mon Oct 23 18:45:52 2006
@@ -12,7 +12,7 @@
import org.xml.sax.Attributes;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.joran.spi.Pattern;
@@ -37,7 +37,7 @@
* @return Whether the implicit action is applicable in the current context
*/
public abstract boolean isApplicable(
- Pattern currentPattern, Attributes attributes, ExecutionContext ec);
+ Pattern currentPattern, Attributes attributes, InterpretationContext ec);
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/MatcherAction.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/MatcherAction.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/MatcherAction.java Mon Oct 23 18:45:52 2006
@@ -14,7 +14,7 @@
import ch.qos.logback.core.boolex.JaninoEventEvaluatorBase;
import ch.qos.logback.core.boolex.Matcher;
import ch.qos.logback.core.joran.spi.ActionException;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.util.OptionHelper;
@@ -28,7 +28,7 @@
*
* The appender thus generated is placed in the ExecutionContext appender bag.
*/
- public void begin(ExecutionContext ec, String localName, Attributes attributes)
+ public void begin(InterpretationContext ec, String localName, Attributes attributes)
throws ActionException {
matcher = null;
@@ -61,7 +61,7 @@
}
}
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
if (inError) {
return;
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/NOPAction.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/NOPAction.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/NOPAction.java Mon Oct 23 18:45:52 2006
@@ -13,7 +13,7 @@
import org.xml.sax.Attributes;
import ch.qos.logback.core.joran.action.Action;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
/**
@@ -25,10 +25,10 @@
*/
public class NOPAction extends Action {
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
}
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
}
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedComponentIA.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedComponentIA.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedComponentIA.java Mon Oct 23 18:45:52 2006
@@ -14,7 +14,7 @@
import org.xml.sax.Attributes;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.joran.spi.Pattern;
import ch.qos.logback.core.spi.ContextAware;
import ch.qos.logback.core.spi.LifeCycle;
@@ -44,7 +44,7 @@
Stack<ImplicitActionData> actionDataStack = new Stack<ImplicitActionData>();
public boolean isApplicable(
- Pattern pattern, Attributes attributes, ExecutionContext ec) {
+ Pattern pattern, Attributes attributes, InterpretationContext ec) {
//LogLog.debug("in NestComponentIA.isApplicable <" + pattern + ">");
String nestedElementTagName = pattern.peekLast();
@@ -72,7 +72,7 @@
}
public void begin(
- ExecutionContext ec, String localName, Attributes attributes) {
+ InterpretationContext ec, String localName, Attributes attributes) {
//LogLog.debug("in NestComponentIA begin method");
// get the action data object pushed in isApplicable() method call
ImplicitActionData actionData = (ImplicitActionData) actionDataStack.peek();
@@ -112,7 +112,7 @@
}
}
- public void end(ExecutionContext ec, String tagName) {
+ public void end(InterpretationContext ec, String tagName) {
// pop the action data object pushed in isApplicable() method call
// we assume that each this begin
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 Mon Oct 23 18:45:52 2006
@@ -16,7 +16,7 @@
import org.xml.sax.Attributes;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.joran.spi.Pattern;
import ch.qos.logback.core.util.PropertySetter;
@@ -41,7 +41,7 @@
Stack<ImplicitActionData> actionDataStack = new Stack<ImplicitActionData>();
public boolean isApplicable(
- Pattern pattern, Attributes attributes, ExecutionContext ec) {
+ Pattern pattern, Attributes attributes, InterpretationContext ec) {
//LogLog.debug("in NestComponentIA.isApplicable <" + pattern + ">");
String nestedElementTagName = pattern.peekLast();
@@ -69,20 +69,21 @@
}
public void begin(
- ExecutionContext ec, String localName, Attributes attributes) {
+ InterpretationContext ec, String localName, Attributes attributes) {
// NOP
}
- public void body(ExecutionContext ec, String body) {
-
+ public void body(InterpretationContext ec, String body) {
+
String finalBody = ec.subst(body);
+ System.out.println("body "+body+", finalBody="+finalBody);
// get the action data object pushed in isApplicable() method call
ImplicitActionData actionData = (ImplicitActionData) actionDataStack.peek();
actionData.parentBean.setProperty(actionData.propertyName, finalBody);
}
- public void end(ExecutionContext ec, String tagName) {
+ public void end(InterpretationContext ec, String tagName) {
// pop the action data object pushed in isApplicable() method call
actionDataStack.pop();
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/NewRuleAction.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/NewRuleAction.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/NewRuleAction.java Mon Oct 23 18:45:52 2006
@@ -12,7 +12,7 @@
import org.xml.sax.Attributes;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.joran.spi.Pattern;
import ch.qos.logback.core.util.OptionHelper;
@@ -23,7 +23,7 @@
/**
* Instantiates an layout of the given class and sets its name.
*/
- public void begin(ExecutionContext ec, String localName, Attributes attributes) {
+ public void begin(InterpretationContext ec, String localName, Attributes attributes) {
// Let us forget about previous errors (in this object)
inError = false;
String errorMsg;
@@ -61,9 +61,9 @@
* Once the children elements are also parsed, now is the time to activate the
* appender options.
*/
- public void end(ExecutionContext ec, String n) {
+ public void end(InterpretationContext ec, String n) {
}
- public void finish(ExecutionContext ec) {
+ public void finish(InterpretationContext ec) {
}
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/ParamAction.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/ParamAction.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/ParamAction.java Mon Oct 23 18:45:52 2006
@@ -13,7 +13,7 @@
import org.xml.sax.Attributes;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.util.PropertySetter;
@@ -24,7 +24,7 @@
boolean inError = false;
public void begin(
- ExecutionContext ec, String localName, Attributes attributes) {
+ InterpretationContext ec, String localName, Attributes attributes) {
String name = attributes.getValue(NAME_ATTRIBUTE);
String value = attributes.getValue(VALUE_ATTRIBUTE);
@@ -55,9 +55,9 @@
propSetter.setProperty(name, value);
}
- public void end(ExecutionContext ec, String localName) {
+ public void end(InterpretationContext ec, String localName) {
}
- public void finish(ExecutionContext ec) {
+ public void finish(InterpretationContext ec) {
}
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/PropertyAction.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/PropertyAction.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/PropertyAction.java Mon Oct 23 18:45:52 2006
@@ -11,7 +11,7 @@
import org.xml.sax.Attributes;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.pattern.util.EscapeUtil;
import ch.qos.logback.core.util.OptionHelper;
@@ -32,8 +32,8 @@
"In <property> element, either the \"file\" attribute or both the \"name\" and \"value\" attributes must be set.";
- abstract void setProperties(ExecutionContext ec, Properties props);
- abstract void setProperty(ExecutionContext ec, String key, String value);
+ abstract void setProperties(InterpretationContext ec, Properties props);
+ abstract void setProperty(InterpretationContext ec, String key, String value);
/**
* Set a new property for the execution context by name, value pair, or adds
@@ -41,7 +41,7 @@
*
*/
public void begin(
- ExecutionContext ec, String localName, Attributes attributes) {
+ InterpretationContext ec, String localName, Attributes attributes) {
String name = attributes.getValue(NAME_ATTRIBUTE);
String value = attributes.getValue(NAME_ATTRIBUTE);
String fileName = attributes.getValue(FILE_ATTRIBUTE);
@@ -75,9 +75,9 @@
}
}
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
}
- public void finish(ExecutionContext ec) {
+ public void finish(InterpretationContext ec) {
}
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/RepositoryPropertyAction.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/RepositoryPropertyAction.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/RepositoryPropertyAction.java Mon Oct 23 18:45:52 2006
@@ -3,7 +3,7 @@
import java.util.Properties;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
/**
@@ -13,14 +13,16 @@
/**
* Add all the properties found in the argument named 'props' to an ExecutionContext.
- *
*/
- @SuppressWarnings("unchecked")
- public void setProperties(ExecutionContext ec, Properties props) {
- this.context.getPropertyMap().putAll(props);
+ public void setProperties(InterpretationContext ec, Properties props) {
+ // TODO : test this method
+ for(Object o: props.keySet()) {
+ String key = (String) o;
+ this.context.setProperty(key, props.getProperty(key));
+ }
}
- public void setProperty(ExecutionContext ec, String key, String value) {
+ public void setProperty(InterpretationContext ec, String key, String value) {
this.context.setProperty(key, value);
}
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/SubstitutionPropertyAction.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/SubstitutionPropertyAction.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/SubstitutionPropertyAction.java Mon Oct 23 18:45:52 2006
@@ -12,7 +12,7 @@
import java.util.Properties;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
/**
* This action sets new substitution properties for the execution context by
@@ -23,11 +23,16 @@
*/
public class SubstitutionPropertyAction extends PropertyAction {
- public void setProperties(ExecutionContext ec, Properties props) {
+ public void setProperties(InterpretationContext ec, Properties props) {
ec.addProperties(props);
+// for(Object o: props.keySet()) {
+// String key = (String) o;
+// ec.getContext().setProperty(key, props.getProperty(key));
+// }
}
- public void setProperty(ExecutionContext ec, String key, String value) {
+ public void setProperty(InterpretationContext ec, String key, String value) {
ec.addProperty(key, value);
+ //ec.getContext().setProperty(key, value);
}
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEventRecorder.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEventRecorder.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEventRecorder.java Mon Oct 23 18:45:52 2006
@@ -34,8 +34,12 @@
public class SaxEventRecorder extends DefaultHandler implements ContextAware {
- ContextAwareImpl cai = new ContextAwareImpl();
-
+
+ final ContextAwareImpl cai;
+
+ public SaxEventRecorder() {
+ cai = new ContextAwareImpl(this);
+ }
public List<SaxEvent> saxEventList = new ArrayList<SaxEvent>();
Locator locator;
Pattern globalPattern = new Pattern();
Copied: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/InterpretationContext.java (from r734, /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/InterpretationContext.java Mon Oct 23 18:45:52 2006
@@ -19,13 +19,11 @@
import org.xml.sax.Locator;
+import ch.qos.logback.core.Context;
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;
-import ch.qos.logback.core.status.WarnStatus;
import ch.qos.logback.core.util.OptionHelper;
@@ -37,56 +35,19 @@
*
* @author Ceki Gülcü
*/
-public class ExecutionContext extends ContextAwareBase {
+public class InterpretationContext extends ContextAwareBase {
Stack<Object> objectStack;
Map<String, Object> objectMap;
- Properties substitutionProperties;
+ Map<String, String> substitutionMap;
Interpreter joranInterpreter;
final List<InPlayListener> listenerList = new ArrayList<InPlayListener>();
- public ExecutionContext(Interpreter joranInterpreter) {
+ public InterpretationContext(Context context, Interpreter joranInterpreter) {
this.joranInterpreter = joranInterpreter;
objectStack = new Stack<Object> ();
objectMap = new HashMap<String, Object>(5);
- substitutionProperties = new Properties();
+ substitutionMap = new HashMap<String, String>();
}
-
- // /**
- // * Clear the internal structures for reuse of the execution context
- // *
- // */
- // public void clear() {
- // objectStack.clear();
- // objectMap.clear();
- // errorList.clear();
- // substitutionProperties.clear();
- // }
-
- public void addError(String msg, Object origin) {
- msg = updateLocationInfo(msg);
- addStatus(new ErrorStatus(msg, origin));
- }
-
- public void addError(String msg, Object origin, Exception e) {
- msg = updateLocationInfo(msg);
- addStatus(new ErrorStatus(msg, origin, e));
- }
-
- public void addWarn(String msg, Object origin) {
- msg = updateLocationInfo(msg);
- addStatus(new WarnStatus(msg, origin));
- }
-
- public void addWarn(String msg, Object origin, Exception e) {
- msg = updateLocationInfo(msg);
- addStatus(new WarnStatus(msg, origin, e));
- }
-
- public void addInfo(String msg, Object origin) {
- msg = updateLocationInfo(msg);
- addStatus(new InfoStatus(msg, origin));
- }
-
String updateLocationInfo(String msg) {
Locator locator = joranInterpreter.getLocator();
@@ -146,7 +107,7 @@
// values with leading or trailing spaces are bad. We remove them now.
value = value.trim();
- substitutionProperties.put(key, value);
+ substitutionMap.put(key, value);
}
public void addProperties(Properties props) {
@@ -161,19 +122,19 @@
}
public String getSubstitutionProperty(String key) {
- return substitutionProperties.getProperty(key);
+ return substitutionMap.get(key);
}
public String subst(String value) {
if (value == null) {
return null;
}
- return OptionHelper.substVars(value, substitutionProperties);
+ return OptionHelper.substVars(value, substitutionMap, context.getPropertyMap());
}
public void addInPlayListener(InPlayListener ipl) {
if(listenerList.contains(ipl)) {
- System.out.println("InPlayListener "+ipl+" has been already registered");
+ addWarn("InPlayListener "+ipl+" has been already registered");
} else {
listenerList.add(ipl);
}
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 Mon Oct 23 18:45:52 2006
@@ -18,11 +18,13 @@
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
+import ch.qos.logback.core.Context;
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;
+import ch.qos.logback.core.spi.ContextAwareImpl;
/**
* <id>Interpreter</id> is Joran's main driving class. It extends SAX
@@ -57,12 +59,13 @@
* @author Ceki Gülcuü
*
*/
-public class Interpreter {
+public class Interpreter {
private static List EMPTY_LIST = new Vector(0);
final private RuleStore ruleStore;
- final private ExecutionContext ec;
+ final private InterpretationContext ec;
final private ArrayList<ImplicitAction> implicitActions;
+ final private ContextAwareImpl cai;
Pattern pattern;
Locator locator;
@@ -82,15 +85,17 @@
*/
Pattern skip = null;
- public Interpreter(RuleStore rs) {
- ruleStore = rs;
- ec = new ExecutionContext(this);
+ public Interpreter(Context context, RuleStore rs) {
+ this.cai = new ContextAwareImpl(this);
+ this.cai.setContext(context);
+ ruleStore = rs;
+ ec = new InterpretationContext(context, this);
implicitActions = new ArrayList<ImplicitAction>(3);
pattern = new Pattern();
actionListStack = new Stack<List>();
}
- public ExecutionContext getExecutionContext() {
+ public InterpretationContext getExecutionContext() {
return ec;
}
@@ -197,7 +202,7 @@
* one element.
*/
List lookupImplicitAction(Pattern pattern, Attributes attributes,
- ExecutionContext ec) {
+ InterpretationContext ec) {
int len = implicitActions.size();
for (int i = 0; i < len; i++) {
@@ -265,7 +270,7 @@
} catch (Exception e) {
skip = (Pattern) pattern.clone();
// getLogger().info("Skip pattern set to <{}>", skip);
- ec.addError("Exception in Action for tag <" + tagName + ">", this, e);
+ cai.addError("Exception in Action for tag <" + tagName + ">", e);
}
}
}
@@ -281,8 +286,7 @@
try {
action.body(ec, body);
} catch (ActionException ae) {
- ec.addError("Exception in end() methd for action [" + action + "]",
- this, ae);
+ cai.addError("Exception in end() methd for action [" + action + "]", ae);
}
}
}
@@ -313,7 +317,7 @@
}
// getLogger().info("Skip pattern set to <{}>", skip);
} catch (Exception e) {
- ec.addError("Exception in Action for tag <" + tagName + ">", this, e);
+ cai.addError("Exception in Action for tag <" + tagName + ">", e);
skip = (Pattern) pattern.clone();
skip.pop(); // induce the siblings to be skipped
// getLogger().info("Skip pattern set to <{}>.", skip);
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java Mon Oct 23 18:45:52 2006
@@ -213,8 +213,8 @@
}
public void rollover() throws RolloverFailure {
- addInfo("roll-over called");
- addInfo("compressionMode: " + compressionMode);
+ //addInfo("roll-over called");
+ //addInfo("compressionMode: " + compressionMode);
if (activeFileName == null) {
switch (compressionMode) {
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/spi/ContextAwareBase.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/spi/ContextAwareBase.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/spi/ContextAwareBase.java Mon Oct 23 18:45:52 2006
@@ -9,14 +9,78 @@
*/
package ch.qos.logback.core.spi;
+import ch.qos.logback.core.Context;
+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.StatusManager;
+import ch.qos.logback.core.status.WarnStatus;
+
/**
- * A helper class that implements ContextAware methods. This class can be either
- * extended or alternatively included as a component.
+ * A helper class that implements ContextAware methods. A class can implement
+ * the ContextAware interface by deriving from this class.
*
* @author Ceki Gülcü
*/
-public class ContextAwareBase extends ContextAwareImpl {
- // to be removed
+public class ContextAwareBase implements ContextAware {
+ private int noContextWarning = 0;
+ protected Context context;
+
+ public void setContext(Context context) {
+ if (this.context == null) {
+ this.context = context;
+ } else if (this.context != context) {
+ throw new IllegalStateException("Context has been already set");
+ }
+ }
+
+ public Context getContext() {
+ return this.context;
+ }
+
+ public StatusManager getStatusManager() {
+ if (context == null) {
+ return null;
+ }
+ return context.getStatusManager();
+ }
+
+ public void addStatus(Status status) {
+ if (context == null) {
+ if (noContextWarning++ == 0) {
+ System.out.println("LOGBACK: No context given for " + this);
+ }
+ return;
+ }
+ StatusManager sm = context.getStatusManager();
+ if (sm != null) {
+ sm.add(status);
+ }
+ }
+
+ public void addInfo(String msg) {
+ addStatus(new InfoStatus(msg, this));
+ }
+
+ public void addInfo(String msg, Throwable ex) {
+ addStatus(new InfoStatus(msg, this, ex));
+ }
+
+ public void addWarn(String msg) {
+ addStatus(new WarnStatus(msg, this));
+ }
+
+ public void addWarn(String msg, Throwable ex) {
+ addStatus(new WarnStatus(msg, this, ex));
+ }
+
+ public void addError(String msg) {
+ addStatus(new ErrorStatus(msg, this));
+ }
+
+ public void addError(String msg, Throwable ex) {
+ addStatus(new ErrorStatus(msg, this, ex));
+ }
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/spi/ContextAwareImpl.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/spi/ContextAwareImpl.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/spi/ContextAwareImpl.java Mon Oct 23 18:45:52 2006
@@ -18,16 +18,21 @@
/**
- * A helper class that implements ContextAware methods. This class can be either
- * extended or alternatively included as a component.
+ * A helper class that implements ContextAware methods. Use this class to
+ * implement the ContextAware interface by composition.
*
* @author Ceki Gülcü
*/
-public class ContextAwareImpl implements ContextAware {
+final public class ContextAwareImpl implements ContextAware {
private int noContextWarning = 0;
protected Context context;
-
+ final Object origin;
+
+ public ContextAwareImpl(Object origin) {
+ this.origin = origin;
+ }
+
public void setContext(Context context) {
if (this.context == null) {
this.context = context;
@@ -61,27 +66,27 @@
}
public void addInfo(String msg) {
- addStatus(new InfoStatus(msg, this));
+ addStatus(new InfoStatus(msg, origin));
}
public void addInfo(String msg, Throwable ex) {
- addStatus(new InfoStatus(msg, this, ex));
+ addStatus(new InfoStatus(msg, origin, ex));
}
public void addWarn(String msg) {
- addStatus(new WarnStatus(msg, this));
+ addStatus(new WarnStatus(msg, origin));
}
public void addWarn(String msg, Throwable ex) {
- addStatus(new WarnStatus(msg, this, ex));
+ addStatus(new WarnStatus(msg, origin, ex));
}
public void addError(String msg) {
- addStatus(new ErrorStatus(msg, this));
+ addStatus(new ErrorStatus(msg, origin));
}
public void addError(String msg, Throwable ex) {
- addStatus(new ErrorStatus(msg, this, ex));
+ addStatus(new ErrorStatus(msg, origin, ex));
}
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java Mon Oct 23 18:45:52 2006
@@ -1,5 +1,5 @@
/**
- * LOGBack: the reliable, fast and flexible logging library for Java.
+ * Logback: the generic, reliable, fast and flexible logging framework.
*
* Copyright (C) 1999-2006, QOS.ch
*
@@ -9,7 +9,7 @@
*/
package ch.qos.logback.core.util;
-import java.util.Properties;
+import java.util.Map;
import ch.qos.logback.core.CoreGlobal;
@@ -39,19 +39,19 @@
* Then perform variable substitution on the found value.
*
*/
- public static String findAndSubst(String key, Properties props) {
- String value = props.getProperty(key);
-
- if (value == null) {
- return null;
- }
-
- try {
- return substVars(value, props);
- } catch (IllegalArgumentException e) {
- return value;
- }
- }
+// public static String findAndSubst(String key, Properties props) {
+// String value = props.getProperty(key);
+//
+// if (value == null) {
+// return null;
+// }
+//
+// try {
+// return substVars(value, props);
+// } catch (IllegalArgumentException e) {
+// return value;
+// }
+// }
final static String DELIM_START = "${";
final static char DELIM_STOP = '}';
@@ -59,25 +59,24 @@
final static int DELIM_STOP_LEN = 1;
/**
* Perform variable substitution in string <code>val</code> from the values
- * of keys found the properties passed as parameter or in the system
- * properties.
+ * of keys found the primary map passed as first parameter, then in the secondary
+ * map, and last in the system properties.
*
* <p>
* The variable substitution delimeters are <b>${</b> and <b>}</b>.
*
* <p>
- * For example, if the properties parameter contains a property "key1" set as
+ * For example, if the primary map parameter contains a property "key1" set as
* "value1", then the call
*
* <pre>
- * String s = OptionConverter.substituteVars("Value of key is ${key1}.");
+ * String s = OptionConverter.substituteVars("Value of key is ${key1}.", priMap, null);
* </pre>
- *
* will set the variable <code>s</code> to "Value of key is value1.".
*
* <p>
- * If no value could be found for the specified key, then the system
- * properties are searched, if the value could not be found there, then
+ * If no value could be found for the specified key, then the secondary map is searches,
+ * and if that fails, the system properties are searched, if that fails, then
* substitution defaults to the empty string.
*
* <p>
@@ -86,7 +85,7 @@
*
* <pre>
* String s = OptionConverter
- * .subsVars("Value of inexistentKey is [${inexistentKey}]");
+ * .subsVars("Value of inexistentKey is [${inexistentKey}]", priMap, null);
* </pre>
*
* will set <code>s</code> to "Value of inexistentKey is []".
@@ -113,7 +112,7 @@
* @throws IllegalArgumentException
* if <code>val</code> is malformed.
*/
- public static String substVars(String val, Properties props) {
+ public static String substVars(String val, Map<String, String> primaryMap, Map<String, String> secondaryMap) {
StringBuffer sbuf = new StringBuffer();
@@ -155,8 +154,12 @@
String replacement = null;
// first try the props passed as parameter
- if (props != null) {
- replacement = props.getProperty(key);
+ if (primaryMap != null) {
+ replacement = primaryMap.get(key);
+ }
+
+ if(replacement == null && secondaryMap != null) {
+ replacement = secondaryMap.get(key);
}
// then try in System properties
@@ -176,7 +179,7 @@
// where the properties are
// x1=p1
// x2=${x1}
- String recursiveReplacement = substVars(replacement, props);
+ String recursiveReplacement = substVars(replacement, primaryMap, secondaryMap);
sbuf.append(recursiveReplacement);
}
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 Mon Oct 23 18:45:52 2006
@@ -22,12 +22,8 @@
import java.beans.Introspector;
import java.beans.MethodDescriptor;
import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
-import java.lang.reflect.*;
-
-import java.util.*;
-
-import ch.qos.logback.core.Appender;
import ch.qos.logback.core.spi.ContextAwareBase;
/**
@@ -96,33 +92,33 @@
* Set the properties for the object that match the <code>prefix</code>
* passed as parameter.
*/
- public void setProperties(Properties properties, String prefix) {
- int len = prefix.length();
-
- for (Enumeration e = properties.propertyNames(); e.hasMoreElements();) {
- String key = (String) e.nextElement();
-
- // handle only properties that start with the desired frefix.
- 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+"].");
- continue;
- }
-
- String value = OptionHelper.findAndSubst(key, properties);
-
- key = key.substring(len);
-
- if ("layout".equals(key) && obj instanceof Appender) {
- continue;
- }
-
- setProperty(key, value);
- }
- }
- }
+// public void setProperties(Properties properties, String prefix) {
+// int len = prefix.length();
+//
+// for (Enumeration e = properties.propertyNames(); e.hasMoreElements();) {
+// String key = (String) e.nextElement();
+//
+// // handle only properties that start with the desired frefix.
+// 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+"].");
+// continue;
+// }
+//
+// String value = OptionHelper.findAndSubst(key, properties);
+//
+// key = key.substring(len);
+//
+// if ("layout".equals(key) && obj instanceof Appender) {
+// continue;
+// }
+//
+// setProperty(key, value);
+// }
+// }
+// }
/**
* Set a property on this PropertySetter's Object. If successful, this method
Added: logback/trunk/logback-core/src/test/input/joran/fruitWithSubst.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/input/joran/fruitWithSubst.xml Mon Oct 23 18:45:52 2006
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<group>
+ <fruitShell name="fs0">
+ <fruit class="ch.qos.logback.core.joran.replay.WeightytFruit">
+ <name>${fruitKey}</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/joran/action/BadBeginAction.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/BadBeginAction.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/BadBeginAction.java Mon Oct 23 18:45:52 2006
@@ -13,7 +13,7 @@
import org.xml.sax.Attributes;
import ch.qos.logback.core.joran.action.Action;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
@@ -23,10 +23,10 @@
public BadBeginAction() {
}
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
throw new IllegalStateException("bad begin");
}
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
}
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/BadEndAction.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/BadEndAction.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/BadEndAction.java Mon Oct 23 18:45:52 2006
@@ -14,17 +14,17 @@
import org.xml.sax.Attributes;
import ch.qos.logback.core.joran.action.Action;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
public class BadEndAction extends Action {
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
}
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
throw new IllegalStateException("bad end");
}
}
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 Mon Oct 23 18:45:52 2006
@@ -12,7 +12,7 @@
import org.xml.sax.Attributes;
import ch.qos.logback.core.joran.action.Action;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
@@ -25,7 +25,7 @@
* Instantiates an layout of the given class and sets its name.
*
*/
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
String str = "Hello "+attributes.getValue("name")+".";
ec.getContext().setProperty("hello", str);
}
@@ -34,6 +34,6 @@
* Once the children elements are also parsed, now is the time to activate
* the appender options.
*/
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
}
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/IncAction.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/IncAction.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/IncAction.java Mon Oct 23 18:45:52 2006
@@ -14,7 +14,7 @@
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.joran.spi.InterpretationContext;
@@ -28,7 +28,7 @@
* Instantiates an layout of the given class and sets its name.
*
*/
- public void begin(ExecutionContext ec, String name, Attributes attributes) throws ActionException {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) throws ActionException {
//System.out.println("IncAction Begin called");
beginCount++;
String val = attributes.getValue("increment");
@@ -42,7 +42,7 @@
* Once the children elements are also parsed, now is the time to activate
* the appender options.
*/
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
endCount++;
}
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/StackCounterAction.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/StackCounterAction.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/StackCounterAction.java Mon Oct 23 18:45:52 2006
@@ -15,7 +15,7 @@
import ch.qos.logback.core.Layout;
import ch.qos.logback.core.joran.action.Action;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
@@ -29,7 +29,7 @@
* Instantiates an layout of the given class and sets its name.
*
*/
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
//String str = "Pushing "+name+"-begin";
ec.pushObject(name+"-begin");
}
@@ -38,11 +38,11 @@
* Once the children elements are also parsed, now is the time to activate
* the appender options.
*/
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
//String str = "Pushing "+name+"-end";
ec.pushObject(name+"-end");
}
- public void finish(ExecutionContext ec) {
+ public void finish(InterpretationContext ec) {
}
}
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 Mon Oct 23 18:45:52 2006
@@ -14,7 +14,7 @@
import org.xml.sax.Attributes;
import ch.qos.logback.core.joran.action.Action;
-import ch.qos.logback.core.joran.spi.ExecutionContext;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
@@ -28,7 +28,7 @@
* Instantiates an layout of the given class and sets its name.
*
*/
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
Integer i = (Integer) ec.getContext().getObject(KEY);
if(i == null) {
ec.getContext().putObject(KEY, new Integer(1));
@@ -41,6 +41,6 @@
* Once the children elements are also parsed, now is the time to activate
* the appender options.
*/
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
}
}
Modified: 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/ListenAction.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/ListenAction.java Mon Oct 23 18:45:52 2006
@@ -17,20 +17,20 @@
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.joran.spi.InterpretationContext;
public class ListenAction extends Action implements InPlayListener {
List<SaxEvent> seList = new ArrayList<SaxEvent>();
@Override
- public void begin(ExecutionContext ec, String name, Attributes attributes)
+ public void begin(InterpretationContext ec, String name, Attributes attributes)
throws ActionException {
ec.addInPlayListener(this);
}
@Override
- public void end(ExecutionContext ec, String name) throws ActionException {
+ public void end(InterpretationContext ec, String name) throws ActionException {
ec.removeInPlayListener(this);
}
Modified: 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/FruitConfigurationTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitConfigurationTest.java Mon Oct 23 18:45:52 2006
@@ -3,9 +3,11 @@
import java.util.HashMap;
import java.util.List;
+import junit.framework.Test;
import junit.framework.TestCase;
-import ch.qos.logback.core.joran.action.NOPAction;
+import junit.framework.TestSuite;
import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.action.NOPAction;
import ch.qos.logback.core.joran.spi.Pattern;
import ch.qos.logback.core.util.Constants;
import ch.qos.logback.core.util.StatusPrinter;
@@ -76,4 +78,25 @@
assertEquals("orange", fruit1.getName());
assertEquals(1.2, ((WeightytFruit) fruit1).getWeight());
}
+
+ public void testWithSubst() throws Exception {
+ List<FruitShell> fsList = doFirstPart("fruitWithSubst.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 WeightytFruit);
+ assertEquals("orange-0", fruit0.getName());
+ assertEquals(1.2, ((WeightytFruit) fruit0).getWeight());
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ suite.addTest(new FruitConfigurationTest("testWithSubst"));
+ //suite.addTestSuite(FruitConfigurationTest.class);
+ return suite;
+ }
}
Modified: 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/FruitFactory.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitFactory.java Mon Oct 23 18:45:52 2006
@@ -9,6 +9,8 @@
public class FruitFactory {
+ static int count = 0;
+
List<SaxEvent> eventList;
Fruit fruit;
@@ -22,6 +24,9 @@
}
Context context = new ContextBase();
this.fruit = null;
+ context.setProperty("fruitKey", "orange-"+count);
+ // for next round
+ count++;
FruitConfigurator fruitConfigurator = new FruitConfigurator(this);
fruitConfigurator.setContext(context);
try {
Modified: 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/FruitFactoryAction.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitFactoryAction.java Mon Oct 23 18:45:52 2006
@@ -19,20 +19,20 @@
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;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
public class FruitFactoryAction extends Action implements InPlayListener {
List<SaxEvent> seList = new ArrayList<SaxEvent>();
@Override
- public void begin(ExecutionContext ec, String name, Attributes attributes)
+ public void begin(InterpretationContext ec, String name, Attributes attributes)
throws ActionException {
ec.addInPlayListener(this);
}
@Override
- public void end(ExecutionContext ec, String name) throws ActionException {
+ public void end(InterpretationContext ec, String name) throws ActionException {
ec.removeInPlayListener(this);
Object o = ec.peekObject();
Modified: 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/FruitShellAction.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitShellAction.java Mon Oct 23 18:45:52 2006
@@ -14,7 +14,7 @@
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.joran.spi.InterpretationContext;
import ch.qos.logback.core.util.OptionHelper;
public class FruitShellAction extends Action {
@@ -24,7 +24,7 @@
@Override
- public void begin(ExecutionContext ec, String name, Attributes attributes)
+ public void begin(InterpretationContext ec, String name, Attributes attributes)
throws ActionException {
// We are just beginning, reset variables
@@ -56,7 +56,7 @@
}
@Override
- public void end(ExecutionContext ec, String name) throws ActionException {
+ public void end(InterpretationContext ec, String name) throws ActionException {
if (inError) {
return;
}
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 Mon Oct 23 18:45:52 2006
@@ -137,35 +137,35 @@
class XAction extends Action {
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
}
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
}
- public void finish(ExecutionContext ec) {
+ public void finish(InterpretationContext ec) {
}
}
class YAction extends Action {
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
}
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
}
- public void finish(ExecutionContext ec) {
+ public void finish(InterpretationContext ec) {
}
}
class ZAction extends Action {
- public void begin(ExecutionContext ec, String name, Attributes attributes) {
+ public void begin(InterpretationContext ec, String name, Attributes attributes) {
}
- public void end(ExecutionContext ec, String name) {
+ public void end(InterpretationContext ec, String name) {
}
- public void finish(ExecutionContext ec) {
+ public void finish(InterpretationContext ec) {
}
}
}
1
0

svn commit: r740 - logback/trunk/logback-core/src/main/java/ch/qos/logback/core/helpers
by noreply.seb@qos.ch 23 Oct '06
by noreply.seb@qos.ch 23 Oct '06
23 Oct '06
Author: seb
Date: Mon Oct 23 17:09:10 2006
New Revision: 740
Modified:
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/helpers/CssBuilder.java
Log:
modified default CSS (mainly changed some colors)
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/helpers/CssBuilder.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/helpers/CssBuilder.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/helpers/CssBuilder.java Mon Oct 23 17:09:10 2006
@@ -48,10 +48,10 @@
buf.append("TR.even { background: #FFFFFF; }");
buf.append(LINE_SEP);
- buf.append("TR.odd { background: #DADADA; }");
+ buf.append("TR.odd { background: #EAEAEA; }");
buf.append(LINE_SEP);
- buf.append("TR.warn TD.level, TR.error TD.level, TR.fatal TD.level {font-weight: bold; color: #FF4040 }");
+ buf.append("TR.warn TD.Level, TR.error TD.Level, TR.fatal TD.Level {font-weight: bold; color: #FF4040 }");
buf.append(LINE_SEP);
buf.append("TD { padding-right: 1ex; padding-left: 1ex; border-right: 2px solid #AAA; }");
@@ -69,10 +69,10 @@
buf.append("TD.Logger { text-align: left; }");
buf.append(LINE_SEP);
- buf.append("TR.header { background: #9090FF; color: #FFF; font-weight: bold; font-size: larger; }");
+ buf.append("TR.header { background: #596ED5; color: #FFF; font-weight: bold; font-size: larger; }");
buf.append(LINE_SEP);
- buf.append("TD.Exception { background: #C0C0F0; font-family: courier, monospace;}");
+ buf.append("TD.Exception { background: #A2AEE8; font-family: courier, monospace;}");
buf.append(LINE_SEP);
buf.append("</STYLE>");
1
0

svn commit: r739 - logback/trunk/logback-site/src/site/xdocTemplates
by noreply.seb@qos.ch 23 Oct '06
by noreply.seb@qos.ch 23 Oct '06
23 Oct '06
Author: seb
Date: Mon Oct 23 11:40:01 2006
New Revision: 739
Modified:
logback/trunk/logback-site/src/site/xdocTemplates/accessLogJetty.xml
logback/trunk/logback-site/src/site/xdocTemplates/joran.xml
logback/trunk/logback-site/src/site/xdocTemplates/shortIntro.xml
Log:
Modified existing source excerpt to use the new css rules.
Unfortunately, we cannot use the rule with the old way of declaring
source excerpts because the <pre> tag must be present.
Modified: logback/trunk/logback-site/src/site/xdocTemplates/accessLogJetty.xml
==============================================================================
--- logback/trunk/logback-site/src/site/xdocTemplates/accessLogJetty.xml (original)
+++ logback/trunk/logback-site/src/site/xdocTemplates/accessLogJetty.xml Mon Oct 23 11:40:01 2006
@@ -92,15 +92,13 @@
<code>RequestLogImpl</code>, add the following lines
to the jetty configuration file, namely <em>$JETTY_HOME/etc/jetty.xml</em>:
</p>
- <pre>
-<Ref id="requestLog">
+ <div class="source"><pre><Ref id="requestLog">
<Set name="requestLog">
<New id="requestLogImpl"
class="ch.qos.logback.access.jetty.RequestLogImpl">
</New>
</Set>
-</Ref>
- </pre>
+</Ref></pre></div>
<p>
These lines reference the requestLog functionnality of Jetty, setting
the actual class that will be called at each logging request.
@@ -127,24 +125,21 @@
jetty configuration file, with a path to the logback access
configuration file.
</p>
- <pre>
-<Ref id="requestLog">
+ <div class="source"><pre><Ref id="requestLog">
<Set name="requestLog">
<New id="requestLogImpl"
class="ch.qos.logback.access.jetty.RequestLogImpl">
</New>
<Set name="fileName">path/to/myaccess.xml</Set>
</Set>
-</Ref>
- </pre>
+</Ref></pre></div>
<h2>Example 1: logback-access configuration</h2>
<p>
Here is a sample <em>logback-access.xml</em> file that you can
immediately put to use:
</p>
- <pre>
-<configuration>
+<div class="source"><pre><configuration>
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
<layout
@@ -154,8 +149,7 @@
</appender>
<appender-ref ref="STDOUT" />
-</configuration>
- </pre>
+</configuration></pre></div>
<p>
It declares a <code>ConsoleAppender</code> which directs its
output at the console. The <code>ConsoleAppender</code> contains
@@ -171,9 +165,9 @@
equivalent
</p>
- <div class="source"><Pattern>%h %l %u %user %date "%r" %s %b</Pattern>
+ <div class="source"><pre><Pattern>%h %l %u %user %date "%r" %s %b</Pattern>
<Pattern>common</Pattern>
-<Pattern>clf</Pattern></div>
+<Pattern>clf</Pattern></pre></div>
<p>The so called "combined" format is also widely recognized. It is
defined as the '%h %l %u %t "%r" %s %b "%i{Referer}"
@@ -181,24 +175,22 @@
"combined" as a shorthand. Thus, the following directive
</p>
- <div class="source"><layout class="ch.qos.logback.access.PatternLayout">
+ <div class="source"><pre><layout class="ch.qos.logback.access.PatternLayout">
<Pattern>%h %l %u %t "%r" %s %b "%i{Referer}" "%i{User-Agent}"</Pattern>
-</layout></div>
+</layout></pre></div>
<p>is equivalent to:</p>
- <div class="source"><layout class="ch.qos.logback.access.PatternLayout">
+ <div class="source"><pre><layout class="ch.qos.logback.access.PatternLayout">
<Pattern>combined</Pattern>
-</layout>
- </div>
+</layout></pre></div>
<h2>Example 2: RollingFileAppender</h2>
<p>Another configuration file, using logback'
<code>RollingFileAppender</code>, could be:</p>
- <pre>
-<configuration>
+<div class="source"><pre><configuration>
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy
@@ -213,8 +205,7 @@
</appender>
<appender-ref ref="FILE" />
-</configuration>
- </pre>
+</configuration></pre></div>
<p>
Here, there is no output to the console. Instead, logback access
Modified: logback/trunk/logback-site/src/site/xdocTemplates/joran.xml
==============================================================================
--- logback/trunk/logback-site/src/site/xdocTemplates/joran.xml (original)
+++ logback/trunk/logback-site/src/site/xdocTemplates/joran.xml Mon Oct 23 11:40:01 2006
@@ -119,7 +119,7 @@
</p>
-<div class="source">package ch.qos.logback.core.joran.action;
+<div class="source"><pre>package ch.qos.logback.core.joran.action;
import org.xml.sax.Attributes;
import ch.qos.logback.core.joran.spi.ExecutionContext;
@@ -140,8 +140,7 @@
* have been processed.
*/
public abstract void end(ExecutionContext ec, String name);
-}
-</div>
+}</pre></div>
<p>Thus, every action must implement the begin and end methods.</p>
@@ -243,13 +242,13 @@
</p>
<p>The <em>calculator2.xml</em> file is a bit more complex, and much more interesting.</p>
<p>It contains the following elements:</p>
-<source><computation name="toto">
+<div class="source"><pre><computation name="toto">
<literal value="7"/>
<literal value="3"/>
<add/>
<literal value="3"/>
<multiply/>
-</computation></source>
+</computation></pre></div>
<p>
Here, there are obviously more actions that will be part of the computation.
</p>
@@ -265,7 +264,7 @@
<p>Finally, a <em>calculator3.xml</em> is also provided, to demonstrate the possibility
elements that contain instances of the same element. Here's the content of
<em>calculator3.xml</em>:</p>
-<source><computation name="toto">
+<div class="source"><pre><computation name="toto">
<computation>
<literal value="7"/>
<literal value="3"/>
@@ -274,7 +273,7 @@
<literal value="3"/>
<multiply/>
-</computation></source>
+</computation></pre></div>
<p>Much like the use of parentheses in an algebrical equation, the presence of
a <code>computation</code> element nested in another is managed by the
@@ -305,12 +304,12 @@
<p>Here is how new rules can be declared in an xml file:</p>
-<div class="source"><new-rule pattern="*/computation/literal" actionClass="joran.calculator.LiteralAction"/></div>
+<div class="source"><pre><new-rule pattern="*/computation/literal" actionClass="joran.calculator.LiteralAction"/></pre></div>
<p>Using new rule declarations, the preceding example, involving the calculation, could be
expressed this way:</p>
-<div class="source"><computation name="toto">
+<div class="source"><pre><computation name="toto">
<new-rule pattern="*/computation/literal"
actionClass="joran.calculator.LiteralAction"/>
<new-rule pattern="*/computation/add"
@@ -326,7 +325,7 @@
<literal value="3"/>
<multiply/>
-</computation></div>
+</computation></pre></div>
<a name="implicit" />
<h3>Implicit actions </h3>
@@ -402,7 +401,7 @@
<p>The <em>implicit1.xml</em> file contains the following lines:</p>
-<source><foo>
+<div class="source"><pre><foo>
<xyz printme="true">
<abc printme="true"/>
@@ -412,7 +411,7 @@
<foo printme="true"/>
-</foo></source>
+</foo></pre></div>
<p>As one can see, the first element will be printed, since it has a <em>printme</em>
attribute, which bears the value <code>true</code>.</p>
@@ -426,10 +425,10 @@
<p>Running the example yields the following output:</p>
-<div class="source">Element <xyz> asked to be printed.
+<div class="source"><pre>Element <xyz> asked to be printed.
Element <abc> asked to be printed.
ERROR in ch.qos.logback.core.joran.spi.ExecutionContext@1c5c1 - no applicable action \
-for <xyz>, current pattern is [/foo/xyz]</div>
+for <xyz>, current pattern is [/foo/xyz]</pre></div>
<p>The last line was printed because of a call to <code>StatusPrinter</code> at the end
of the main class.</p>
Modified: logback/trunk/logback-site/src/site/xdocTemplates/shortIntro.xml
==============================================================================
--- logback/trunk/logback-site/src/site/xdocTemplates/shortIntro.xml (original)
+++ logback/trunk/logback-site/src/site/xdocTemplates/shortIntro.xml Mon Oct 23 11:40:01 2006
@@ -97,7 +97,7 @@
</p>
<em>Example 1.1: Basic template for logging (examples/chapter1/HelloWorld1.java)</em>
-<div class="source">package chapter1;
+<div class="source"><pre>package chapter1;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -110,7 +110,7 @@
logger.debug("Hello world.");
}
-}</div>
+}</pre></div>
<p>
The <code>HelloWorld</code> class is defined in the
@@ -147,7 +147,7 @@
Once you're in the <em>examples/classes</em> directory of the logback distribution, you can run this class with the command:
</p>
- <div class="source">java chapter1.HelloWorld1</div>
+ <div class="source"><pre>java chapter1.HelloWorld1</pre></div>
<p>
Suprisingly enough, launching the <code>HelloWorld1</code>
@@ -167,7 +167,7 @@
</p>
<em>Example 1.2: Printing Logger Status (examples/chapter1/HelloWorld2.java)</em>
-<div class="source">package chapter1;
+<div class="source"><pre>package chapter1;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -180,14 +180,14 @@
logger.debug("Hello world.");
<b>LoggerStatusPrinter.printStatusInDefaultContext();</b>
}
-}</div>
+}</pre></div>
<p>Running the <code>HelloWorld2</code> application will produce
the following output:</p>
-<div class="source">ERROR in Logger[chapter1.HelloWorld2] - No appenders present in \
-context [default] for logger [chapter1.HelloWorld2].</div>
+<div class="source"><pre>ERROR in Logger[chapter1.HelloWorld2] - No appenders present in \
+context [default] for logger [chapter1.HelloWorld2].</pre></div>
<!-- ========= CEKI: STOPPED HERE =================== -->
@@ -207,7 +207,7 @@
<code>BasicConfigurator</code> class, like in the following code snippet.
</p>
<em>Example 1.3: Configuring before logging (examples/chapter1/HelloWorld3.java)</em>
- <div class="source">package chapter1;
+ <div class="source"><pre>package chapter1;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -224,7 +224,7 @@
LoggerStatusPrinter.printStatusInDefaultContext();
}
-}</div>
+}</pre></div>
<p>
Let's run the <code>HelloWorld3</code>
@@ -233,7 +233,7 @@
The logging request will then be propagated to the
<code>Appender</code> and the console will output the following:
</p>
-<div class="source">0 [main] DEBUG chapter1.HelloWorld3 - Hello world.</div>
+<div class="source"><pre>0 [main] DEBUG chapter1.HelloWorld3 - Hello world.</pre></div>
<p>
This example is rather simple. However, actual logging in a larger
@@ -317,7 +317,7 @@
It is exceptional in that it always exists. Like every
logger, it can be retrieved by its name, like this:
</p>
- <div class="source">Logger rootLogger = LoggerFactory.getLogger(LoggerContext.<em>ROOT_NAME</em>);</div>
+ <div class="source"><pre>Logger rootLogger = LoggerFactory.getLogger(LoggerContext.<em>ROOT_NAME</em>);</pre></div>
<p>
All other loggers are also retrieved with the class static
@@ -326,7 +326,7 @@
methods in the <code>Logger</code> interface are listed below.
</p>
- <div class="source">package org.slf4j;
+ <div class="source"><pre>package org.slf4j;
public interface Logger {
// Printing methods:
@@ -335,7 +335,7 @@
public void warn(String message);
public void error(String message);
public void fatal(String message);
-}</div>
+}</pre></div>
<p>
Loggers may be assigned levels. The set of possible levels,
@@ -646,7 +646,7 @@
<p>Here is an example of the basic selection rule.</p>
- <div class="source">// get a logger instance named "com.foo", with an <span class="blue">INFO</span> level.
+ <div class="source"><pre>// get a logger instance named "com.foo", with an <span class="blue">INFO</span> level.
Logger logger = LoggerFactory.getLogger("com.foo");
//set its Level to <span class="blue">INFO</span>
logger.setLevel(Level.INFO);
@@ -665,7 +665,7 @@
barlogger.<span class="green">info</span>("Located nearest gas station.");
// This request is disabled, because<span class="green">DEBUG</span> < <span class="blue">INFO</span>.
-barlogger.<span class="green">debug</span>("Exiting gas station search");</div>
+barlogger.<span class="green">debug</span>("Exiting gas station search");</pre></div>
<h3>Retrieving Loggers</h3>
<p>
@@ -675,8 +675,8 @@
</p>
<p>For example, in</p>
- <div class="source">Logger x = LoggerFactory.getLogger("wombat");
-Logger y = LoggerFactory.getLogger("wombat");</div>
+ <div class="source"><pre>Logger x = LoggerFactory.getLogger("wombat");
+Logger y = LoggerFactory.getLogger("wombat");</pre></div>
<p>
<code>x</code> and <code>y</code> refer to
@@ -862,7 +862,7 @@
"%-4relative [%thread] %-5level %class - %msg%n" will output something akin to:
</p>
- <div class="source">176 [main] DEBUG chapter1.HelloWorld3 - Hello world.</div>
+ <div class="source"><pre>176 [main] DEBUG chapter1.HelloWorld3 - Hello world.</pre></div>
<p>
The first field is the number of milliseconds elapsed since
@@ -885,7 +885,7 @@
For some Logger <code>logger</code>, writing,
</p>
- <div class="source">logger.debug("Entry number: " + i + " is " + String.valueOf(entry[i]));</div>
+ <div class="source"><pre>logger.debug("Entry number: " + i + " is " + String.valueOf(entry[i]));</pre></div>
<p>
incurs the cost of constructing the message parameter, that
@@ -900,9 +900,9 @@
example.
</p>
- <div class="source">if(logger.isDebugEnabled()) {
+ <div class="source"><pre>if(logger.isDebugEnabled()) {
logger.debug("Entry number: " + i + " is " + String.valueOf(entry[i]));
-}</div>
+}</pre></div>
<p>
@@ -925,8 +925,8 @@
</p>
- <div class="source">Object entry = new SomeObject();
-logger.debug("The entry is {}.", entry);</div>
+ <div class="source"><pre>Object entry = new SomeObject();
+logger.debug("The entry is {}.", entry);</pre></div>
<p>
After evaluting whether to log or not, and only if the
@@ -946,8 +946,8 @@
factor of at least 30.
</p>
- <div class="source">logger.debug("The new entry is "+entry+".");
-logger.debug("The new entry is {}.", entry);</div>
+ <div class="source"><pre>logger.debug("The new entry is "+entry+".");
+logger.debug("The new entry is {}.", entry);</pre></div>
<p>
@@ -955,7 +955,7 @@
can write:
</p>
- <div class="source">logger.debug("The new entry is {}. It replaces {}.", entry, oldEntry);</div>
+ <div class="source"><pre>logger.debug("The new entry is {}. It replaces {}.", entry, oldEntry);</pre></div>
<p>
If three or more arguments need to be passed, an <code>Object[]</code>
@@ -963,8 +963,8 @@
</p>
- <div class="source">Object[] paramArray = {newVal, below, above};
-logger.debug("Value {} was inserted between {} and {}.", paramArray);</div>
+ <div class="source"><pre>Object[] paramArray = {newVal, below, above};
+logger.debug("Value {} was inserted between {} and {}.", paramArray);</pre></div>
<h3>Configuration</h3>
@@ -992,7 +992,7 @@
imaginary application MyApp that uses logback.
</p>
<em>Example 1.4: Basic configuration (examples/chapter1/MyApp.java)</em>
-<div class="source">package chapter1;
+<div class="source"><pre>package chapter1;
// Import SLF4J classes.
import org.slf4j.LoggerFactory;
@@ -1014,20 +1014,20 @@
bar.doIt();
logger.info("Exiting application.");
}
-}</div>
+}</pre></div>
<p>
This class defines a logger instance variable
with the name MyApp. It then uses the Bar class, defined as shown below:
</p>
<em>Example 1.4: Basic configuration (examples/chapter1/Bar.java)</em>
-<div class="source">class Bar {
+<div class="source"><pre>class Bar {
Logger logger = LoggerFactory.getLogger(Bar.class);
public void doIt() {
logger.debug("doing my job");
}
-}</div>
+}</pre></div>
<p>
The invocation of the BasicConfigurator create, as we have seen,
a simple yet sufficient logback setup. By default,
@@ -1038,14 +1038,14 @@
<p>
The output of MyApp is:
</p>
-<div class="source">0 [main] INFO ch.qos.logback.classic.examples.MyApp - Entering application.
+<div class="source"><pre>0 [main] INFO ch.qos.logback.classic.examples.MyApp - Entering application.
0 [main] DEBUG ch.qos.logback.classic.examples.Bar - doing my job
-0 [main] INFO ch.qos.logback.classic.examples.MyApp - Exiting application.</div>
+0 [main] INFO ch.qos.logback.classic.examples.MyApp - Exiting application.</pre></div>
<p>Let's configure logback to do exactly the same output, this time
with an XML configuration file.</p>
<em>Example 1.4: Basic configuration (examples/chapter1/sample-config-1.xml)</em>
-<div class="source"><?xml version="1.0" encoding="UTF-8" ?>
+<div class="source"><pre><?xml version="1.0" encoding="UTF-8" ?>
<configuration>
@@ -1061,7 +1061,7 @@
<level value="debug" />
<appender-ref ref="STDOUT" />
</root>
-</configuration></div>
+</configuration></pre></div>
<p>We first created an <code>Appender</code>, named <em>STDOUT</em> that is of <code>ConsoleAppender</code> tye. Its layout
is managed by a PatternLayout, that uses the value of the "pattern" parameter to generate
@@ -1072,13 +1072,13 @@
<p>To run this examle, use this command:</p>
-<div class="source">java chapter1.MyApp sample-config-1.xml</div>
+<div class="source"><pre>java chapter1.MyApp sample-config-1.xml</pre></div>
<p>The console output will be exactly the same as before. However, this time, we didn't need
to import and call the BasicConfigurator class, as you can see in the following code section:
</p>
<em>Example 1.5: Logback configuration from file (examples/chapter1/MyAppWithConfigFile.java)</em>
-<div class="source">package chapter1;
+<div class="source"><pre>package chapter1;
//Import SLF4J classes.
import org.slf4j.Logger;
@@ -1105,7 +1105,7 @@
StatusPrinter.print(lc.getStatusManager());
}
-}</div>
+}</pre></div>
<p>
We used the JoranConfigurator class to parse the configuration file we just created.
Joran is a XML interpreter, similar to the commons-digester API, but offering several
@@ -1119,7 +1119,7 @@
<p>Logging to the console is a rather simple example. Let's now configure logback
so that it logs to the console, but also to a custom file.</p>
<em>Example 1.5: Logback configuration from file (examples/chapter1/sample-config-2.xml)</em>
-<div class="source"><?xml version="1.0" encoding="UTF-8" ?>
+<div class="source"><pre><?xml version="1.0" encoding="UTF-8" ?>
<configuration>
@@ -1146,7 +1146,7 @@
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
-</configuration></div>
+</configuration></pre></div>
<p>Now, all the logging statements are directed to the console and to a file named <em>sample-log.txt</em>.
As you can see, the configuration needed to add an Appender is rather small. The param element, in either
@@ -1158,7 +1158,7 @@
This is done by adding the following xml snippet to the configuration file, right before
the <code><root></code> element.</p>
<em>Example 1.5: Logback configuration from file (examples/chapter1/sample-config-3.xml)</em>
-<div class="source"><?xml version="1.0" encoding="UTF-8" ?>
+<div class="source"><pre><?xml version="1.0" encoding="UTF-8" ?>
<configuration>
@@ -1190,12 +1190,12 @@
<appender-ref ref="FILE" />
</root>
</configuration>
-</div>
+</pre></div>
<p>This done, the output is modified to show only statements of level INFO and higher.</p>
-<div class="source">0 [main] INFO chapter1.MyAppWithConfigFile - Entering application.
-0 [main] INFO chapter1.MyAppWithConfigFile - Exiting application.</div>
+<div class="source"><pre>0 [main] INFO chapter1.MyAppWithConfigFile - Entering application.
+0 [main] INFO chapter1.MyAppWithConfigFile - Exiting application.</pre></div>
<p>Note that to obtain these different logging behaviors we did not need to recompile code.
We could just as easily have logged to a UNIX Syslog daemon, redirected all chapter1 output
1
0

svn commit: r738 - in logback/trunk/logback-site/src/site: . resources xdocTemplates
by noreply.ceki@qos.ch 21 Oct '06
by noreply.ceki@qos.ch 21 Oct '06
21 Oct '06
Author: ceki
Date: Sat Oct 21 20:07:51 2006
New Revision: 738
Modified:
logback/trunk/logback-site/src/site/resources/10reasons.ppt
logback/trunk/logback-site/src/site/site.xml
logback/trunk/logback-site/src/site/xdocTemplates/index.xml
Log:
minor modifs
Modified: logback/trunk/logback-site/src/site/resources/10reasons.ppt
==============================================================================
Binary files. No diff available.
Modified: logback/trunk/logback-site/src/site/site.xml
==============================================================================
--- logback/trunk/logback-site/src/site/site.xml (original)
+++ logback/trunk/logback-site/src/site/site.xml Sat Oct 21 20:07:51 2006
@@ -12,6 +12,7 @@
<bannerLeft>
<name>${project.name}</name>
<src>/images/logos/lblogo.jpg</src>
+ <href>http://logback.qos.ch</href>
</bannerLeft>
<body>
Modified: logback/trunk/logback-site/src/site/xdocTemplates/index.xml
==============================================================================
--- logback/trunk/logback-site/src/site/xdocTemplates/index.xml (original)
+++ logback/trunk/logback-site/src/site/xdocTemplates/index.xml Sat Oct 21 20:07:51 2006
@@ -9,13 +9,32 @@
<body>
+ <h3>10 reasons to switch to logback</h3>
+
+ <p>
+ <a href=" http://tinyurl.com/yjcq33"> <img border="0" src="images/hortisMG.gif"/></a>
+ </p>
+
+ <p>On the 5th of December, Ceki Gülcü will be presenting
+ (in French) top 10 reasons for migrating your projects to
+ logback. Issues such as migration strategy, new APIs, SLF4J and
+ Joran will be discussed. Emphasis will be given to practical
+ aspects and a live demo rather than relatively theoretical
+ considerations.
+ </p>
+
+ <p>This <a href=" http://tinyurl.com/yjcq33">free-entry event</a>
+ is organized in colloboration with <a
+ href="http://www.hortis.ch">Hortis SA</a>.</p>
+
+
+
<h2>Logback Project</h2>
<p>
Logback is intended as a successor to the popular log4j
- project. It was also designed by Ceki Gülc�, the
- founder of the log4j project. It builds upon exerience gained in
- building industrial-strength logging systems going back as far
- as 1999.
+ project. It was designed by Ceki Gülc�, the founder of the
+ log4j project. It builds upon exerience gained in building
+ industrial-strength logging systems going back as far as 1999.
</p>
<p>
Logback's basic architecture is sufficiently generic so as to
1
0

svn commit: r737 - in logback/trunk/logback-classic/src: main/java/ch/qos/logback/classic/net test/java/ch/qos/logback/classic/net
by noreply.ceki@qos.ch 21 Oct '06
by noreply.ceki@qos.ch 21 Oct '06
21 Oct '06
Author: ceki
Date: Sat Oct 21 18:47:57 2006
New Revision: 737
Modified:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/NOPOutputStream.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfsTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketMin.java
Log:
Commit limited to lincesing or cosmetic changes
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java Sat Oct 21 18:47:57 2006
@@ -1,5 +1,5 @@
/**
- * Logback: the reliable, generic, fast and flexible logging framework.
+ * Logback: the generic, reliable, fast and flexible logging framework.
*
* Copyright (C) 1999-2006, QOS.ch
*
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java Sat Oct 21 18:47:57 2006
@@ -1,5 +1,5 @@
/**
- * Logback: the reliable, generic, fast and flexible logging framework.
+ * Logback: the generic, reliable, fast and flexible logging framework.
*
* Copyright (C) 1999-2006, QOS.ch
*
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/NOPOutputStream.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/NOPOutputStream.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/NOPOutputStream.java Sat Oct 21 18:47:57 2006
@@ -1,3 +1,13 @@
+/**
+ * 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.classic.net;
import java.io.IOException;
@@ -5,10 +15,10 @@
public class NOPOutputStream extends OutputStream {
- @Override
- public void write(int b) throws IOException {
- // do nothing
+ @Override
+ public void write(int b) throws IOException {
+ // do nothing
- }
+ }
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfsTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfsTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfsTest.java Sat Oct 21 18:47:57 2006
@@ -11,177 +11,177 @@
public class SerializationPerfsTest extends TestCase {
- ObjectOutputStream oos;
+ ObjectOutputStream oos;
- int loopNumber = 10000;
- int resetFrequency = 100;
- int pauseFrequency = 10;
- long pauseLengthInMillis = 20;
-
- /**
- * <p>
- * Run the test with a MockSocketServer or with a NOPOutputStream
- * </p>
- * <p>
- * Run with external mock can be done using the ExternalMockSocketServer. It
- * needs to be launched from a separate JVM. The ExternalMockSocketServer does
- * not consume the events but passes through the available bytes that it is
- * recieving.
- * </p>
- * <p>
- * For example, with 4 test methods, you can launch the
- * ExternalMockSocketServer this way:
- * </p>
- * <p>
- * <code>java ch.qos.logback.classic.net.ExternalMockSocketServer 4</code>
- * </p>
- */
- boolean runWithExternalMockServer = true;
-
- /**
- * Last results:
- * Data sent mesured in kilobytes.
- * Avg time mesured in microsecs.
- *
- * NOPOutputStream:
- * | | Runs | Avg time | Data sent |
- * | MinimalObj Ext | 10000 | | |
- * | MinimalObj Ser | 10000 | | |
- * | LoggEvent Ext | 10000 | | |
- * | LoggEvent Ser | 10000 | | |
- *
- * External MockServer with 45 letters-long message: on localhost
- * (always the same message)
- * | | Runs | Avg time | Data sent |
- * | MinimalObj Ext | 10000 | - | - |
- * | MinimalObj Ser | 10000 | 74 | 248 |
- * | LoggEvent Ext | 10000 | - | - |
- * | LoggEvent Ser | 10000 | 156 | 835 |
- * pauseFrequency = 10 and pauseLengthInMillis = 20
- *
- * External MockServer with 45 letters-long message: on localhost
- * (different message each time)
- * | | Runs | Avg time | Data sent |
- * | MinimalObj Ext | 10000 | | |
- * | MinimalObj Ser | 10000 | 73 | 1139 |
- * | LoggEvent Ext | 10000 | | |
- * | LoggEvent Ser | 10000 | 162 | 1752 |
- * pauseFrequency = 10 and pauseLengthInMillis = 20
- *
- * External MockServer with 45 letters-long message: on PIXIE
- * (always the same message)
- * | | Runs | Avg time | Data sent |
- * | MinimalObj Ext | 10000 | - | - |
- * | MinimalObj Ser | 10000 | 29 | 248 |
- * | LoggEvent Ext | 10000 | - | - |
- * | LoggEvent Ser | 10000 | 42 | 835 |
- * pauseFrequency = 10 and pauseLengthInMillis = 20
- *
- * External MockServer with 45 letters-long message: on PIXIE
- * (different message each time)
- * | | Runs | Avg time | Data sent |
- * | MinimalObj Ext | 10000 | | |
- * | MinimalObj Ser | 10000 | 27 | 1139 |
- * | LoggEvent Ext | 10000 | | |
- * | LoggEvent Ser | 10000 | 44 | 1752 |
- * pauseFrequency = 10 and pauseLengthInMillis = 20
- *
- */
-
- public void setUp() throws Exception {
- super.setUp();
- if (runWithExternalMockServer) {
- oos = new ObjectOutputStream(new Socket("pixie",
- ExternalMockSocketServer.PORT).getOutputStream());
- } else {
- oos = new ObjectOutputStream(new NOPOutputStream());
- }
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- oos.close();
- oos = null;
- }
-
- public void runPerfTest(Builder builder, String label) throws Exception {
- // long time1 = System.nanoTime();
-
- // Object builtObject = builder.build(1);
-
- // first run for just in time compiler
- int resetCounter = 0;
- int pauseCounter = 0;
- for (int i = 0; i < loopNumber; i++) {
- try {
- oos.writeObject(builder.build(i));
- oos.flush();
- if (++resetCounter >= resetFrequency) {
- oos.reset();
- resetCounter = 0;
- }
- if (++pauseCounter >= pauseFrequency) {
- Thread.sleep(pauseLengthInMillis);
- pauseCounter = 0;
- }
-
- } catch (IOException ex) {
- fail(ex.getMessage());
- }
- }
-
- // second run
- Long t1;
- Long t2;
- Long total = 0L;
- resetCounter = 0;
- pauseCounter = 0;
- // System.out.println("Beginning mesured run");
- for (int i = 0; i < loopNumber; i++) {
- try {
- t1 = System.nanoTime();
- oos.writeObject(builder.build(i));
- oos.flush();
- t2 = System.nanoTime();
- total += (t2 - t1);
- if (++resetCounter >= resetFrequency) {
- oos.reset();
- resetCounter = 0;
- }
- if (++pauseCounter >= pauseFrequency) {
- Thread.sleep(pauseLengthInMillis);
- pauseCounter = 0;
- }
- } catch (IOException ex) {
- fail(ex.getMessage());
- }
- }
- total /= 1000;
- System.out.println(label + " : average time = " + total / loopNumber
- + " microsecs after " + loopNumber + " writes.");
-
- // long time2 = System.nanoTime();
- // System.out.println("********* -> Time needed to run the test method: " +
- // Long.toString(time2-time1));
- }
-
-// public void testWithMinimalExternalization() throws Exception {
-// Builder builder = new MinimalExtBuilder();
-// runPerfTest(builder, "Minimal object externalization");
-// }
-
- public void testWithMinimalSerialization() throws Exception {
- Builder builder = new MinimalSerBuilder();
- runPerfTest(builder, "Minimal object serialization");
- }
-
-// public void testWithExternalization() throws Exception {
-// Builder builder = new LoggingEventExtBuilder();
-// runPerfTest(builder, "LoggingEvent object externalization");
-// }
-
- public void testWithSerialization() throws Exception {
- Builder builder = new LoggingEventBuilder();
- runPerfTest(builder, "LoggingEvent object serialization");
- }
+ int loopNumber = 10000;
+ int resetFrequency = 100;
+ int pauseFrequency = 10;
+ long pauseLengthInMillis = 20;
+
+ /**
+ * <p>
+ * Run the test with a MockSocketServer or with a NOPOutputStream
+ * </p>
+ * <p>
+ * Run with external mock can be done using the ExternalMockSocketServer. It
+ * needs to be launched from a separate JVM. The ExternalMockSocketServer does
+ * not consume the events but passes through the available bytes that it is
+ * recieving.
+ * </p>
+ * <p>
+ * For example, with 4 test methods, you can launch the
+ * ExternalMockSocketServer this way:
+ * </p>
+ * <p>
+ * <code>java ch.qos.logback.classic.net.ExternalMockSocketServer 4</code>
+ * </p>
+ */
+ boolean runWithExternalMockServer = true;
+
+ /**
+ * Last results:
+ * Data sent mesured in kilobytes.
+ * Avg time mesured in microsecs.
+ *
+ * NOPOutputStream:
+ * | | Runs | Avg time | Data sent |
+ * | MinimalObj Ext | 10000 | | |
+ * | MinimalObj Ser | 10000 | | |
+ * | LoggEvent Ext | 10000 | | |
+ * | LoggEvent Ser | 10000 | | |
+ *
+ * External MockServer with 45 letters-long message: on localhost
+ * (always the same message)
+ * | | Runs | Avg time | Data sent |
+ * | MinimalObj Ext | 10000 | - | - |
+ * | MinimalObj Ser | 10000 | 74 | 248 |
+ * | LoggEvent Ext | 10000 | - | - |
+ * | LoggEvent Ser | 10000 | 156 | 835 |
+ * pauseFrequency = 10 and pauseLengthInMillis = 20
+ *
+ * External MockServer with 45 letters-long message: on localhost
+ * (different message each time)
+ * | | Runs | Avg time | Data sent |
+ * | MinimalObj Ext | 10000 | | |
+ * | MinimalObj Ser | 10000 | 73 | 1139 |
+ * | LoggEvent Ext | 10000 | | |
+ * | LoggEvent Ser | 10000 | 162 | 1752 |
+ * pauseFrequency = 10 and pauseLengthInMillis = 20
+ *
+ * External MockServer with 45 letters-long message: on PIXIE
+ * (always the same message)
+ * | | Runs | Avg time | Data sent |
+ * | MinimalObj Ext | 10000 | - | - |
+ * | MinimalObj Ser | 10000 | 29 | 248 |
+ * | LoggEvent Ext | 10000 | - | - |
+ * | LoggEvent Ser | 10000 | 42 | 835 |
+ * pauseFrequency = 10 and pauseLengthInMillis = 20
+ *
+ * External MockServer with 45 letters-long message: on PIXIE
+ * (different message each time)
+ * | | Runs | Avg time | Data sent |
+ * | MinimalObj Ext | 10000 | | |
+ * | MinimalObj Ser | 10000 | 27 | 1139 |
+ * | LoggEvent Ext | 10000 | | |
+ * | LoggEvent Ser | 10000 | 44 | 1752 |
+ * pauseFrequency = 10 and pauseLengthInMillis = 20
+ *
+ */
+
+ public void setUp() throws Exception {
+ super.setUp();
+ if (runWithExternalMockServer) {
+ oos = new ObjectOutputStream(new Socket("pixie",
+ ExternalMockSocketServer.PORT).getOutputStream());
+ } else {
+ oos = new ObjectOutputStream(new NOPOutputStream());
+ }
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ oos.close();
+ oos = null;
+ }
+
+ public void runPerfTest(Builder builder, String label) throws Exception {
+ // long time1 = System.nanoTime();
+
+ // Object builtObject = builder.build(1);
+
+ // first run for just in time compiler
+ int resetCounter = 0;
+ int pauseCounter = 0;
+ for (int i = 0; i < loopNumber; i++) {
+ try {
+ oos.writeObject(builder.build(i));
+ oos.flush();
+ if (++resetCounter >= resetFrequency) {
+ oos.reset();
+ resetCounter = 0;
+ }
+ if (++pauseCounter >= pauseFrequency) {
+ Thread.sleep(pauseLengthInMillis);
+ pauseCounter = 0;
+ }
+
+ } catch (IOException ex) {
+ fail(ex.getMessage());
+ }
+ }
+
+ // second run
+ Long t1;
+ Long t2;
+ Long total = 0L;
+ resetCounter = 0;
+ pauseCounter = 0;
+ // System.out.println("Beginning mesured run");
+ for (int i = 0; i < loopNumber; i++) {
+ try {
+ t1 = System.nanoTime();
+ oos.writeObject(builder.build(i));
+ oos.flush();
+ t2 = System.nanoTime();
+ total += (t2 - t1);
+ if (++resetCounter >= resetFrequency) {
+ oos.reset();
+ resetCounter = 0;
+ }
+ if (++pauseCounter >= pauseFrequency) {
+ Thread.sleep(pauseLengthInMillis);
+ pauseCounter = 0;
+ }
+ } catch (IOException ex) {
+ fail(ex.getMessage());
+ }
+ }
+ total /= 1000;
+ System.out.println(label + " : average time = " + total / loopNumber
+ + " microsecs after " + loopNumber + " writes.");
+
+ // long time2 = System.nanoTime();
+ // System.out.println("********* -> Time needed to run the test method: " +
+ // Long.toString(time2-time1));
+ }
+
+ // public void testWithMinimalExternalization() throws Exception {
+ // Builder builder = new MinimalExtBuilder();
+ // runPerfTest(builder, "Minimal object externalization");
+ // }
+
+ public void testWithMinimalSerialization() throws Exception {
+ Builder builder = new MinimalSerBuilder();
+ runPerfTest(builder, "Minimal object serialization");
+ }
+
+ // public void testWithExternalization() throws Exception {
+ // Builder builder = new LoggingEventExtBuilder();
+ // runPerfTest(builder, "LoggingEvent object externalization");
+ // }
+
+ public void testWithSerialization() throws Exception {
+ Builder builder = new LoggingEventBuilder();
+ runPerfTest(builder, "LoggingEvent object serialization");
+ }
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java Sat Oct 21 18:47:57 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.classic.net;
import java.util.Map;
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketMin.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketMin.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketMin.java Sat Oct 21 18:47:57 2006
@@ -1,5 +1,5 @@
/**
- * Logback: the reliable, generic, fast and flexible logging framework.
+ * Logback: the generic, reliable, fast and flexible logging framework.
*
* Copyright (C) 1999-2006, QOS.ch
*
@@ -20,86 +20,86 @@
public class SocketMin {
- static Logger logger = (Logger) LoggerFactory.getLogger(SocketMin.class
- .getName());
- static SocketAppender s;
-
- public static void main(String argv[]) {
- if (argv.length == 3) {
- init(argv[0], argv[1]);
- } else {
- usage("Wrong number of arguments.");
- }
-
- // NDC.push("some context");
- if (argv[2].equals("true")) {
- loop();
- } else {
- test();
- }
-
- s.stop();
- }
-
- static void usage(String msg) {
- System.err.println(msg);
- System.err.println("Usage: java " + SocketMin.class
- + " host port true|false");
- System.exit(1);
- }
-
- static void init(String host, String portStr) {
- Logger root = (Logger) LoggerFactory.getLogger(LoggerContext.ROOT_NAME);
- BasicConfigurator.configure(root.getLoggerContext());
- try {
- int port = Integer.parseInt(portStr);
- logger.info("Creating socket appender (" + host + "," + port + ").");
- s = new SocketAppender(host, port);
- s.setName("S");
- root.addAppender(s);
- } catch (java.lang.NumberFormatException e) {
- e.printStackTrace();
- usage("Could not interpret port number [" + portStr + "].");
- } catch (Exception e) {
- System.err.println("Could not start!");
- e.printStackTrace();
- System.exit(1);
- }
- }
-
- static void loop() {
- Logger root = (Logger) LoggerFactory.getLogger(LoggerContext.ROOT_NAME);
- InputStreamReader in = new InputStreamReader(System.in);
- System.out.println("Type 'q' to quit");
- int i;
- int k = 0;
- while (true) {
- logger.debug("Message " + k++);
- logger.info("Message " + k++);
- logger.warn("Message " + k++);
- logger.error("Message " + k++, new Exception("Just testing"));
- try {
- i = in.read();
- } catch (Exception e) {
- return;
- }
- if (i == -1)
- break;
- if (i == 'q')
- break;
- if (i == 'r') {
- System.out.println("Removing appender S");
- root.detachAppender("S");
- }
- }
- }
-
- static void test() {
- int i = 0;
- logger.debug("Message " + i++);
- logger.info("Message " + i++);
- logger.warn("Message " + i++);
- logger.error("Message " + i++);
- logger.debug("Message " + i++, new Exception("Just testing."));
- }
+ static Logger logger = (Logger) LoggerFactory.getLogger(SocketMin.class
+ .getName());
+ static SocketAppender s;
+
+ public static void main(String argv[]) {
+ if (argv.length == 3) {
+ init(argv[0], argv[1]);
+ } else {
+ usage("Wrong number of arguments.");
+ }
+
+ // NDC.push("some context");
+ if (argv[2].equals("true")) {
+ loop();
+ } else {
+ test();
+ }
+
+ s.stop();
+ }
+
+ static void usage(String msg) {
+ System.err.println(msg);
+ System.err.println("Usage: java " + SocketMin.class
+ + " host port true|false");
+ System.exit(1);
+ }
+
+ static void init(String host, String portStr) {
+ Logger root = (Logger) LoggerFactory.getLogger(LoggerContext.ROOT_NAME);
+ BasicConfigurator.configure(root.getLoggerContext());
+ try {
+ int port = Integer.parseInt(portStr);
+ logger.info("Creating socket appender (" + host + "," + port + ").");
+ s = new SocketAppender(host, port);
+ s.setName("S");
+ root.addAppender(s);
+ } catch (java.lang.NumberFormatException e) {
+ e.printStackTrace();
+ usage("Could not interpret port number [" + portStr + "].");
+ } catch (Exception e) {
+ System.err.println("Could not start!");
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ static void loop() {
+ Logger root = (Logger) LoggerFactory.getLogger(LoggerContext.ROOT_NAME);
+ InputStreamReader in = new InputStreamReader(System.in);
+ System.out.println("Type 'q' to quit");
+ int i;
+ int k = 0;
+ while (true) {
+ logger.debug("Message " + k++);
+ logger.info("Message " + k++);
+ logger.warn("Message " + k++);
+ logger.error("Message " + k++, new Exception("Just testing"));
+ try {
+ i = in.read();
+ } catch (Exception e) {
+ return;
+ }
+ if (i == -1)
+ break;
+ if (i == 'q')
+ break;
+ if (i == 'r') {
+ System.out.println("Removing appender S");
+ root.detachAppender("S");
+ }
+ }
+ }
+
+ static void test() {
+ int i = 0;
+ logger.debug("Message " + i++);
+ logger.info("Message " + i++);
+ logger.warn("Message " + i++);
+ logger.error("Message " + i++);
+ logger.debug("Message " + i++, new Exception("Just testing."));
+ }
}
1
0

svn commit: r736 - logback/trunk/logback-core/src/main/java/ch/qos/logback/core/status
by noreply.ceki@qos.ch 21 Oct '06
by noreply.ceki@qos.ch 21 Oct '06
21 Oct '06
Author: ceki
Date: Sat Oct 21 18:43:36 2006
New Revision: 736
Modified:
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/status/StatusBase.java
Log:
prefer effectiveLevel to level in toString() method.
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/status/StatusBase.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/status/StatusBase.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/status/StatusBase.java Sat Oct 21 18:43:36 2006
@@ -104,7 +104,7 @@
*/
public String toString() {
StringBuffer buf = new StringBuffer();
- switch (level) {
+ switch (getEffectiveLevel()) {
case INFO:
buf.append("INFO");
break;
1
0