[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. release_0.9.19-15-g4bca7fd

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Wed Mar 31 16:04:48 CEST 2010


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".

The branch, master has been updated
       via  4bca7fd336247b7752488f58f62500463be20579 (commit)
       via  18037a0e5175f739f861be85c2f341e5c249fbf2 (commit)
       via  0348b40b4ea9e290ca147928a45bb20194f54dd4 (commit)
      from  a85c31bd64e687260888e5a9567340c084b01c6e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=4bca7fd336247b7752488f58f62500463be20579
http://github.com/ceki/logback/commit/4bca7fd336247b7752488f58f62500463be20579

commit 4bca7fd336247b7752488f58f62500463be20579
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Wed Mar 31 16:03:23 2010 +0200

    Fixed LBCLASSIC-182 according to the patch suppllied by Aleksey Didik

diff --git a/logback-core/src/test/input/joran/define/good.xml b/logback-core/src/test/input/joran/define/good.xml
index be56cc2..60e9ca1 100644
--- a/logback-core/src/test/input/joran/define/good.xml
+++ b/logback-core/src/test/input/joran/define/good.xml
@@ -1,3 +1,3 @@
-<define name="foo" class="ch.qos.logback.core.joran.action.FooPropertyDefiner">
-    <fooName>Monster</fooName>
-</define>
\ No newline at end of file
+<define name="foo" class="ch.qos.logback.core.joran.action.AsLowerCasePropertyDefiner">
+  <value>MONSTER</value>
+</define>
\ No newline at end of file
diff --git a/logback-core/src/test/input/joran/define/noclass.xml b/logback-core/src/test/input/joran/define/noclass.xml
index 300efaf..60156aa 100644
--- a/logback-core/src/test/input/joran/define/noclass.xml
+++ b/logback-core/src/test/input/joran/define/noclass.xml
@@ -1,3 +1,3 @@
-<define name="foo">
-    <fooName>Monster</fooName>
+<define name="foo">
+  <fooName>Monster</fooName>
 </define>
\ No newline at end of file
diff --git a/logback-core/src/test/input/joran/define/noname.xml b/logback-core/src/test/input/joran/define/noname.xml
index aed88c7..ba9793a 100644
--- a/logback-core/src/test/input/joran/define/noname.xml
+++ b/logback-core/src/test/input/joran/define/noname.xml
@@ -1,3 +1,3 @@
-<define class="ch.qos.logback.core.joran.action.FooPropertyDefiner">
-    <fooName>Monster</fooName>
-</define>
\ No newline at end of file
+<define class="ch.qos.logback.core.joran.action.AsLowerCasePropertyDefiner">
+    <value>Monster</value>
+</define>
\ No newline at end of file
diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/action/FooPropertyDefiner.java b/logback-core/src/test/java/ch/qos/logback/core/joran/action/AsLowerCasePropertyDefiner.java
similarity index 72%
rename from logback-core/src/test/java/ch/qos/logback/core/joran/action/FooPropertyDefiner.java
rename to logback-core/src/test/java/ch/qos/logback/core/joran/action/AsLowerCasePropertyDefiner.java
index e1aa240..361ed55 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/joran/action/FooPropertyDefiner.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/joran/action/AsLowerCasePropertyDefiner.java
@@ -15,15 +15,19 @@ package ch.qos.logback.core.joran.action;
 
 import ch.qos.logback.core.PropertyDefinerBase;
 
-public class FooPropertyDefiner extends PropertyDefinerBase {
+public class AsLowerCasePropertyDefiner extends PropertyDefinerBase {
 
-  private String fooName;
+  String val;
 
   public String getPropertyValue() {
-    return "Foo[" + fooName + "]";
+    if (val == null) {
+      return null;
+    } else {
+      return val.toLowerCase();
+    }
   }
 
-  public void setFooName(String fooName) {
-    this.fooName = fooName;
+  public void setValue(String val) {
+    this.val = val;
   }
 }
diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/action/DefinePropertyActionTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/action/DefinePropertyActionTest.java
index 4514317..ef1704e 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/joran/action/DefinePropertyActionTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/joran/action/DefinePropertyActionTest.java
@@ -18,7 +18,6 @@ import static junit.framework.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import java.util.HashMap;
-import java.util.Iterator;
 
 import org.junit.After;
 import org.junit.Before;
@@ -30,7 +29,8 @@ import ch.qos.logback.core.joran.SimpleConfigurator;
 import ch.qos.logback.core.joran.spi.InterpretationContext;
 import ch.qos.logback.core.joran.spi.JoranException;
 import ch.qos.logback.core.joran.spi.Pattern;
-import ch.qos.logback.core.status.ErrorStatus;
+import ch.qos.logback.core.status.Status;
+import ch.qos.logback.core.status.StatusChecker;
 import ch.qos.logback.core.util.CoreTestConstants;
 
 /**
@@ -40,7 +40,7 @@ import ch.qos.logback.core.util.CoreTestConstants;
  */
 public class DefinePropertyActionTest {
 
-  private static final String DEFINE_XML_DIR = CoreTestConstants.JORAN_INPUT_PREFIX
+  private static final String DEFINE_INPUT_DIR = CoreTestConstants.JORAN_INPUT_PREFIX
       + "define/";
   private static final String GOOD_XML = "good.xml";
   private static final String NONAME_XML = "noname.xml";
@@ -48,82 +48,61 @@ public class DefinePropertyActionTest {
   private static final String BADCLASS_XML = "badclass.xml";
 
   SimpleConfigurator sc;
-  Context context;
+  Context context = new ContextBase();
   DefinePropertyAction definerAction;
   InterpretationContext ic;
+  StatusChecker checker = new StatusChecker(context);
 
   @Before
   public void setUp() throws Exception {
-    context = new ContextBase();
+
     HashMap<Pattern, Action> rulesMap = new HashMap<Pattern, Action>();
     rulesMap.put(new Pattern("define"), new DefinePropertyAction());
     sc = new SimpleConfigurator(rulesMap);
     sc.setContext(context);
+  }
 
+  @After
+  public void tearDown() throws Exception {
+    //StatusPrinter.printInCaseOfErrorsOrWarnings(context);
   }
 
   @Test
-  public void testAllRight() throws JoranException {
-    sc.doConfigure(DEFINE_XML_DIR + GOOD_XML);
+  public void good() throws JoranException {
+    sc.doConfigure(DEFINE_INPUT_DIR + GOOD_XML);
     // get from context
     String inContextFoo = context.getProperty("foo");
-    // get from real class
-    FooPropertyDefiner fooDefiner = new FooPropertyDefiner();
-    fooDefiner.setFooName("Monster");
-    String fromRealClassFoo = fooDefiner.getPropertyValue();
-    assertEquals(inContextFoo, fromRealClassFoo);
+    assertEquals("monster", inContextFoo);
   }
 
   @Test
-  public void testNoName() throws JoranException {
-    sc.doConfigure(DEFINE_XML_DIR + NONAME_XML);
+  public void noName() throws JoranException {
+    sc.doConfigure(DEFINE_INPUT_DIR + NONAME_XML);
     // get from context
     String inContextFoo = context.getProperty("foo");
     assertNull(inContextFoo);
     // check context errors
-    assertTrue(checkError("Missing property name for property definer. Near [define] line 1"));
+    assertTrue(checker.containsMatch(Status.ERROR,
+        "Missing property name for property definer. Near \\[define\\] line 1"));
   }
 
   @Test
-  public void testNoClass() throws JoranException {
-    sc.doConfigure(DEFINE_XML_DIR + NOCLASS_XML);
-    // get from context
+  public void noClass() throws JoranException {
+    sc.doConfigure(DEFINE_INPUT_DIR + NOCLASS_XML);
     String inContextFoo = context.getProperty("foo");
     assertNull(inContextFoo);
-    // check context errors
-    assertTrue(checkError("Missing class name for property definer. Near [define] line 1"));
+    assertTrue(checker.containsMatch(Status.ERROR,
+        "Missing class name for property definer. Near \\[define\\] line 1"));
   }
 
   @Test
   public void testBadClass() throws JoranException {
-    sc.doConfigure(DEFINE_XML_DIR + BADCLASS_XML);
+    sc.doConfigure(DEFINE_INPUT_DIR + BADCLASS_XML);
     // get from context
     String inContextFoo = context.getProperty("foo");
     assertNull(inContextFoo);
     // check context errors
-    assertTrue(checkBadClassError());
-  }
-
-  @After
-  public void tearDown() throws Exception {
-    context = null;
-    sc = null;
-  }
-
-  private boolean checkError(String waitedMsg) {
-    Iterator it = context.getStatusManager().getCopyOfStatusList().iterator();
-    ErrorStatus es1 = (ErrorStatus) it.next();
-    return waitedMsg.equals(es1.getMessage());
-  }
-
-  private boolean checkBadClassError() {
-    Iterator it = context.getStatusManager().getCopyOfStatusList().iterator();
-    // skip info about class instantiating
-    it.next();
-    // check error status
-    ErrorStatus es1 = (ErrorStatus) it.next();
-    return "Could not create an PropertyDefiner of type [a.b.c.Foo]."
-        .equals(es1.getMessage());
+    checker.containsMatch(Status.ERROR, "Could not create an PropertyDefiner of type");
   }
 
 }
diff --git a/logback-site/src/site/pages/manual/configuration.html b/logback-site/src/site/pages/manual/configuration.html
index a1fad9c..86167e4 100644
--- a/logback-site/src/site/pages/manual/configuration.html
+++ b/logback-site/src/site/pages/manual/configuration.html
@@ -1238,13 +1238,13 @@ public class MyApp3 {
   As it often comes in handy, the variable ${HOSTNAME} is
   automatically defined.</p>
 
-  <h4>properties are inserted into the logger context</h4>
+  <h4>Properties are inserted into the logger context</h4>
 
   <p>Note that the values defined via <code>&lt;property></code>
   element are actually inserted into the logger context. In other
   words, they become properties of the logger context.  Consequently,
-  they will be available in all logging events as well as remotely
-  after serialization.</p>
+  they will be available in all logging events, including those sent
+  to remote hosts via serialization.</p>
 
   <p>The next example shows a variable, a.k.a. a substitution
   property, declared the beginning of the configuration file. It is
@@ -1367,7 +1367,6 @@ public class MyApp3 {
    properties file shown below gives an example.
    </p>
 
-
    <em>Example: Nested variable references
    (logback-examples/src/main/java/chapters/configuration/variables2.properties)</em>
 
@@ -1400,9 +1399,9 @@ fileName=myApp.log
   &lt;/root>
 &lt;/configuration></pre>
 
-  <h4><a name="defaultValuesForVariables"
+  <h3><a name="defaultValuesForVariables"
   href="#defaultValuesForVariables">Default substitution values for
-  variables</a></h4>
+  variables</a></h3>
 
   <p>Under certain circumstances, it may be desirable for a variable
   to have a default value in case it is not declared or its value is
@@ -1412,6 +1411,57 @@ fileName=myApp.log
   operator. For example, assuming <em>aKey</em> is not defined,
   <code>"${aKey<b>:-golden</b>}"</code> will be interpreted as
   "golden".</p>
+
+
+  <!-- ============================================================== -->
+  <h3><a name="hostname" href="#hostname">HOSTNAME property</a></h3>
+
+  <p>As it often comes in handy, the <code>HOSTNAME</code> property is
+  defined automatically during configuration.</p>
+
+  <!-- ============================================================== -->
+  
+  <h3><a name="timestamp" href="#timestamp">Setting a timestamp</a></h3>
+
+  <p>The <em>timestamp</em> element can define a property according to
+  current date and time. The <em>timestamp</em> element is <a
+  href="appenders.html#uniquelyNamed">explained in a subsequent
+  chapter</a>.</p>
+
+  <!-- ============================================================== -->
+  <h3><a name="definingPropsOnTheFly"
+  href="#definingPropsOnTheFly">Defining properties on the
+  fly</a></h3>
+
+  <p>You may define properties from within the configuration file
+  using the <code>&lt;define></code> element. The define element takes
+  mandatory attributes: <span class="attr">name</span> and <span
+  class="attr">class</span>. The <span class="attr">name</span>
+  attribute designates the name of the property to set whereas the
+  <span class="attr">class</span> attribute designates any class
+  implementing the <a
+  href="../xref/ch/qos/logback/core/spi/PropertyDefiner.html">PropertyDefiner</a>
+  interface. The value returned by the <code>getPropertyValue</code>()
+  method of the <code>PropertyDefiner</code> will be placed into the
+  named property.
+  </p>
+
+  <p>Here is an example.</p>
+
+  <pre class="prettyprint source">&lt;configuration>
+
+  &lt;define name="rootLevel" class="a.class.implementing.PropertyDefiner">
+    &lt;aProperty>of a.class.implementing.PropertyDefiner&lt;/aProperty>
+  &lt;/define>
+  
+  &lt;root level="${rootLevel}"/>
+&lt;/configuration></pre>
+
+  <p>At present time, logback does not ship with any classes
+  implementing <code>PropertyDefiner</code>. We merely provide an
+  extension point so that you may define properties dynamically.
+  </p>
+
   <!-- ============================================================== -->
 
   <h3><a name="conditional" href="#conditional">Conditional
@@ -1517,7 +1567,6 @@ Nevertheless, recognizing the
   readers of your configuration files, including yourself.
   </p>
 
-  
 
   <!-- ============================================================== -->
 
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index 28310bc..c419888 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -38,6 +38,12 @@
     <p>Logback now supports <a
     href="manual/configuration.html#conditional">conditional
     processing</a> of configuration files.</p>
+
+    <p>A new extension point for <a
+    href="manual/configuration.html#definingPropsOnTheFly">defining
+    properties on the fly</a> has been added. The code for this
+    enhancement was provided by Aleksey Didik in <a
+    href="http://jira.qos.ch/browse/LBCLASSIC-182">LBCLASSIC-182</a>.</p>
     
     <p>Logback now provides <a
     href="http://logback.qos.ch/manual/loggingSeparation.html">an

http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=18037a0e5175f739f861be85c2f341e5c249fbf2
http://github.com/ceki/logback/commit/18037a0e5175f739f861be85c2f341e5c249fbf2

commit 18037a0e5175f739f861be85c2f341e5c249fbf2
Merge: a85c31b 0348b40
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Wed Mar 31 14:29:47 2010 +0200

    Merge branch 'lbclassic182'


-----------------------------------------------------------------------

Summary of changes:
 .../ch/qos/logback/core/PropertyDefinerBase.java   |   13 +++
 .../logback/core/joran/JoranConfiguratorBase.java  |   25 ++---
 .../core/joran/action/DefinePropertyAction.java    |   98 ++++++++++++++++++
 .../Condition.java => spi/PropertyDefiner.java}    |   12 ++-
 .../src/test/input/joran/define/badclass.xml       |    1 +
 logback-core/src/test/input/joran/define/good.xml  |    3 +
 .../src/test/input/joran/define/noclass.xml        |    3 +
 .../src/test/input/joran/define/noname.xml         |    3 +
 .../joran/action/AsLowerCasePropertyDefiner.java}  |   21 +++--
 .../joran/action/DefinePropertyActionTest.java     |  108 ++++++++++++++++++++
 .../src/site/pages/manual/configuration.html       |   63 ++++++++++--
 logback-site/src/site/pages/news.html              |    6 +
 12 files changed, 325 insertions(+), 31 deletions(-)
 create mode 100644 logback-core/src/main/java/ch/qos/logback/core/PropertyDefinerBase.java
 create mode 100644 logback-core/src/main/java/ch/qos/logback/core/joran/action/DefinePropertyAction.java
 copy logback-core/src/main/java/ch/qos/logback/core/{joran/conditional/Condition.java => spi/PropertyDefiner.java} (66%)
 create mode 100644 logback-core/src/test/input/joran/define/badclass.xml
 create mode 100644 logback-core/src/test/input/joran/define/good.xml
 create mode 100644 logback-core/src/test/input/joran/define/noclass.xml
 create mode 100644 logback-core/src/test/input/joran/define/noname.xml
 copy logback-core/src/{main/java/ch/qos/logback/core/joran/conditional/ElseAction.java => test/java/ch/qos/logback/core/joran/action/AsLowerCasePropertyDefiner.java} (57%)
 create mode 100644 logback-core/src/test/java/ch/qos/logback/core/joran/action/DefinePropertyActionTest.java


hooks/post-receive
-- 
Logback: the generic, reliable, fast and flexible logging framework.


More information about the logback-dev mailing list