[logback-dev] svn commit: r1566 - in logback/trunk: . logback-classic/src/main/java/ch/qos/logback/classic/spi logback-classic/src/test/java/ch/qos/logback/classic/spi logback-site/src/site/pages logback-site/src/site/pages/manual

noreply.ceki at qos.ch noreply.ceki at qos.ch
Tue Aug 21 19:41:44 CEST 2007


Author: ceki
Date: Tue Aug 21 19:41:43 2007
New Revision: 1566

Added:
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/CallerDataTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventExt.java
      - copied unchanged from r1563, /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEventExt.java
Removed:
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEventExt.java
Modified:
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/CallerData.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/PackageTest.java
   logback/trunk/logback-site/src/site/pages/index.html
   logback/trunk/logback-site/src/site/pages/manual/architecture.html
   logback/trunk/logback-site/src/site/pages/team.html
   logback/trunk/pom.xml

Log:
- minor doc changes
- fixed bug 78, in relation with failing caller data extraction (reported by Hans van der Meer)
- moved LoggingEventTest to test/

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/CallerData.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/CallerData.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/CallerData.java	Tue Aug 21 19:41:43 2007
@@ -14,6 +14,7 @@
 /**
  * The internal representation of caller location information.
  * 
+ * @author Ceki Gülcü
  */
 public class CallerData implements java.io.Serializable {
 
@@ -35,6 +36,11 @@
   public static String CALLER_DATA_NA = "?#?:?"+CoreGlobal.LINE_SEPARATOR;
 
   /**
+   * This value is returned in case no caller data could be extracted.
+   */
+  public static CallerData[] EMPTY_CALLER_DATA_ARRAY = new CallerData[0];
+  
+  /**
    * Caller's line number.
    */
   int lineNumber;
@@ -83,19 +89,23 @@
     StackTraceElement[] steArray = t.getStackTrace();
     CallerData[] callerDataArray;
     
-    int found = -1;
+    int found = LINE_NA;
     for (int i = 0; i < steArray.length; i++) {
       if(steArray[i].getClassName().equals(fqnOfInvokingClass)) {
         // the caller is assumed to be the next stack frame, hence the +1.
         found = i + 1;
       } else {
-        if(found != -1) {
+        if(found != LINE_NA) {
           break;
         }
       }
-      
     }
 
+    // we failed to extract caller data
+    if(found == LINE_NA) {
+      return EMPTY_CALLER_DATA_ARRAY;
+    }
+    
     callerDataArray = new CallerData[steArray.length - found];
     for (int i = found; i < steArray.length; i++) {
       callerDataArray[i-found] = new CallerData(steArray[i]);

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java	Tue Aug 21 19:41:43 2007
@@ -181,9 +181,14 @@
   /**
    * This method should be called prior to serializing an event. It should also
    * be called when using asynchronous logging.
+   * 
+   * <p>Note that due to performance concerns, this method does NOT extract 
+   * caller data. It is the responsability of the calller to extract caller
+   * information.
    */
   public void prepareForDeferredProcessing() {
     this.getThreadName();
+    
   }
 
   public LoggerRemoteView getLoggerRemoteView() {

Added: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/CallerDataTest.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/CallerDataTest.java	Tue Aug 21 19:41:43 2007
@@ -0,0 +1,40 @@
+package ch.qos.logback.classic.spi;
+
+import junit.framework.TestCase;
+
+public class CallerDataTest extends TestCase {
+
+  public CallerDataTest(String name) {
+    super(name);
+  }
+
+  protected void setUp() throws Exception {
+    super.setUp();
+  }
+
+  protected void tearDown() throws Exception {
+    super.tearDown();
+  }
+
+  public void testBasic() {
+    Throwable t = new Throwable();
+    StackTraceElement[] steArray = t.getStackTrace();
+    
+    CallerData[] cda = CallerData.extract(t, CallerDataTest.class.getName());
+    assertNotNull(cda);
+    assertTrue(cda.length > 0);
+    assertEquals(steArray.length - 1, cda.length);
+  }
+  
+  /**
+   * This test verifies that in case caller data cannot be
+   * extracted, CallerData.extract does not throw an exception
+   *
+   */
+  public void testDeferredProcessing() {
+    CallerData[] cda = CallerData.extract(new Throwable(), "com.inexistent.foo");
+    assertNotNull(cda);
+    assertEquals(0, cda.length);
+  }
+  
+}

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/PackageTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/PackageTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/PackageTest.java	Tue Aug 21 19:41:43 2007
@@ -19,6 +19,7 @@
   public static Test suite() {
     TestSuite suite = new TestSuite();
     suite.addTestSuite(ContextListenerTest.class);
+    suite.addTestSuite(CallerDataTest.class);
     return suite;
   }
 }
\ No newline at end of file

Modified: logback/trunk/logback-site/src/site/pages/index.html
==============================================================================
--- logback/trunk/logback-site/src/site/pages/index.html	(original)
+++ logback/trunk/logback-site/src/site/pages/index.html	Tue Aug 21 19:41:43 2007
@@ -21,33 +21,31 @@
 	
 	
 		<h2>Logback Project</h2>
-		<p>
-			Logback is intended as a successor to the popular log4j
-			project. It was designed by Ceki G&#252;lc&#252;, the founder of the
-			log4j project. It builds upon experience gained in building
-			industrial-strength logging systems going back as far as 1999.
+
+    <p>Logback is intended as a successor to the popular log4j
+    project. It was designed by Ceki G&#252;lc&#252;, the founder of
+    log4j. It builds upon experience 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
-			apply under different circumstances. At present time, logback is
-			divided into three modules, logback-core, logback-classic and
-			logback-access.
+
+    <p>Logback's basic architecture is sufficiently generic so as to
+    apply under different circumstances. At present time, logback is
+    divided into three modules, logback-core, logback-classic and
+    logback-access.
 		</p>
 
-		<p>
-			The logback-core module lays the groundwork for the other two
-			modules. The logback-classic module can be assimilated to a
-			significantly improved version of log4j. Moreover,
-			logback-classic natively implements the <a
-			href="http://www.slf4j.org">SLF4J API</a> so that you can
-			readily switch back and forth between logback and other logging
-			systems such as log4j or JDK14 Logging.
+		<p>The logback-core module lays the groundwork for the other two
+		modules. The logback-classic module can be assimilated to a
+		significantly improved version of log4j. Moreover, logback-classic
+		natively implements the <a href="http://www.slf4j.org">SLF4J
+		API</a> so that you can readily switch back and forth between
+		logback and other logging systems such as log4j or JDK14 Logging.
     </p>
 
-    <p>
-			The Access module integrates with Servlet containers to
-			provide HTTP-access log functionality. Note that you can
-			easily build your own modules on top of the Core module.
+    <p>The logback-access module integrates with Servlet containers,
+    such as Tomcat and Jetty, to provide HTTP-access log
+    functionality. Note that you can easily build your own modules on
+    top of the Core module.
 		</p>
 
 	

Modified: logback/trunk/logback-site/src/site/pages/manual/architecture.html
==============================================================================
--- logback/trunk/logback-site/src/site/pages/manual/architecture.html	(original)
+++ logback/trunk/logback-site/src/site/pages/manual/architecture.html	Tue Aug 21 19:41:43 2007
@@ -801,7 +801,7 @@
   these fields are initialized lazily, that is only when they are
   actually needed. The <code>MDC</code> is used to decorate the
   logging request with additional contextual information. MDC is
-  discussed in a <a href="mdc.html">separate chapter</a>.</p>
+  discussed in a <a href="mdc.html">subsequent chapter</a>.</p>
 
   <h4>4. Invoking appenders</h4>
 

Modified: logback/trunk/logback-site/src/site/pages/team.html
==============================================================================
--- logback/trunk/logback-site/src/site/pages/team.html	(original)
+++ logback/trunk/logback-site/src/site/pages/team.html	Tue Aug 21 19:41:43 2007
@@ -51,15 +51,10 @@
 
           <p>One of the core lessons he has learned over the years is
           that unit tests lie at the heart of maintainable
-          software. Adding tests towards the end of development cycle
-          yields poor results. Tests must be an inherent part of the
-          development process right from the start.
-          </p>
-
-          <p>When not busy programming, Ceki enjoys watching the
-          Simpsons on DVD or alternatively preparing sushis for his
-          friends.
-          </p>
+          software. Adding tests at the end of development cycle
+          yields poor results. Tests must be part of development right
+          from the beginning.
+          </p>         
 
 				</td>
 			</tr>

Modified: logback/trunk/pom.xml
==============================================================================
--- logback/trunk/pom.xml	(original)
+++ logback/trunk/pom.xml	Tue Aug 21 19:41:43 2007
@@ -36,7 +36,7 @@
   
   <properties>
     <!-- slf4j.version property is used below and in setClasspath.cmd -->
-    <slf4j.version>1.4.2</slf4j.version>  
+    <slf4j.version>1.4.3</slf4j.version>  
     <consolePlugin.version>1.0.1</consolePlugin.version>  
     <retrotranslator.verify>false</retrotranslator.verify>
   </properties>



More information about the logback-dev mailing list