commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject cvs commit: jakarta-commons/logging/src/java/org/apache/commons/logging/impl AvalonLogger.java
Date Wed, 14 May 2003 11:12:59 GMT
rdonkin     2003/05/14 04:12:59

  Modified:    logging  build.xml
               logging/src/java/org/apache/commons/logging/impl
                        AvalonLogger.java
  Log:
  Made implementation of AvalonLogger more robust (avoiding NPEs when nulls are passed in)
together with a testcase. Improved build by compiling tests for only those optional components
whose dependencies are present. Submitted by Neeme Praks.
  
  Revision  Changes    Path
  1.37      +50 -2     jakarta-commons/logging/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/logging/build.xml,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- build.xml	7 May 2003 16:02:20 -0000	1.36
  +++ build.xml	14 May 2003 11:12:58 -0000	1.37
  @@ -264,6 +264,39 @@
       </jar>
     </target>
   
  +  <target name='compile.jdk1.4.tests' if='jdk.1.4.present'>
  +    <javac  srcdir="${test.home}"
  +           destdir="${build.home}/tests"
  +             debug="${compile.debug}"
  +       deprecation="${compile.deprecation}"
  +          optimize="${compile.optimize}">
  +      <classpath refid="test.classpath"/>
  +        <include name='**/jdk14/**'/>
  +    </javac>
  +  </target>
  +
  +  <target name='compile.log4j.tests' if='log4j.present'>
  +    <javac  srcdir="${test.home}"
  +           destdir="${build.home}/tests"
  +             debug="${compile.debug}"
  +       deprecation="${compile.deprecation}"
  +          optimize="${compile.optimize}">
  +      <classpath refid="test.classpath"/>
  +        <include name='**/log4j/**'/>
  +    </javac>
  +  </target>
  +
  +
  +  <target name='compile.avalon.tests' if='avalon-framework.present'>
  +    <javac  srcdir="${test.home}"
  +           destdir="${build.home}/tests"
  +             debug="${compile.debug}"
  +       deprecation="${compile.deprecation}"
  +          optimize="${compile.optimize}">
  +      <classpath refid="test.classpath"/>
  +        <include name='**/avalon/**'/>
  +    </javac>
  +  </target>
   
     <target name="compile.tests" depends="compile"
      description="Compile unit test cases">
  @@ -273,7 +306,13 @@
          deprecation="${compile.deprecation}"
             optimize="${compile.optimize}">
         <classpath refid="test.classpath"/>
  +      <exclude name='**/jdk14/**'/>
  +      <exclude name='**/log4j/**'/>
  +      <exclude name='**/avalon/**'/>
       </javac>
  +    <antcall target='compile.log4j.tests'/>
  +    <antcall target='compile.jdk1.4.tests'/>
  +    <antcall target='compile.avalon.tests'/>
       <copy    todir="${build.home}/tests" filtering="on">
         <fileset dir="${test.home}" excludes="**/*.java"/>
       </copy>
  @@ -355,7 +394,7 @@
   <!-- ========== Unit Test Targets ========================================= -->
   
   
  -  <target name="test"  depends="compile.tests,test.jdk14,test.log4j
  +  <target name="test"  depends="compile.tests,test.jdk14,test.log4j,test.avalon
             " if="test.entry"
      description="Run all unit test cases">
         <java classname="${test.runner}" fork="yes" failonerror="${test.failonerror}">
  @@ -605,5 +644,14 @@
   
     </target>
   
  +  <target name="test.avalon" depends="compile.tests" if="avalon-framework.present"
  +   description="Run unit tests specific to Avalon (Framework) logging">
  +
  +    <echo message="Avalon Tests"/>
  +    <java classname="${test.runner}" fork="yes" failonerror="${test.failonerror}">
  +      <arg value="org.apache.commons.logging.avalon.AvalonLoggerTest"/>
  +      <classpath refid="test.classpath"/>
  +    </java>
  +  </target>
   
   </project>
  
  
  
  1.2       +18 -16    jakarta-commons/logging/src/java/org/apache/commons/logging/impl/AvalonLogger.java
  
  Index: AvalonLogger.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/impl/AvalonLogger.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AvalonLogger.java	7 May 2003 16:23:36 -0000	1.1
  +++ AvalonLogger.java	14 May 2003 11:12:58 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/avalon/src/java/org/apache/commons/jelly/avalon/JellyService.java,v
1.1 2003/01/22 09:19:30 jstrachan Exp
  - * 1.1
  - * 2003/01/22 09:19:30
  + * $Header$
  + * $Revision$
  + * $Date$
    *
    * ====================================================================
    *
  @@ -57,7 +57,6 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    *
  - * JellyServiceImpl.java,v 1.1 2003/01/22 09:19:30 jstrachan Exp
    */
   
   package org.apache.commons.logging.impl;
  @@ -70,6 +69,7 @@
    * logging calls to Avalon logging abstraction: the Logger interface.
    * 
    * @author <a href="mailto:neeme@apache.org">Neeme Praks</a>
  + * @version $Revision$ $Date$
    */
   public class AvalonLogger implements Log {
   
  @@ -87,6 +87,8 @@
        * @param logger the avalon logger implementation to delegate to 
        */
       public AvalonLogger(String name) {
  +        if (defaultLogger == null) 
  +            throw new NullPointerException("default logger has to be specified if this
constructor is used!");
           this.logger = defaultLogger.getChildLogger(name);
       }
   
  @@ -108,56 +110,56 @@
        * @see org.apache.commons.logging.Log#debug(java.lang.Object, java.lang.Throwable)
        */
       public void debug(Object o, Throwable t) {
  -        if (this.logger.isDebugEnabled()) this.logger.debug(o.toString(), t);
  +        if (this.logger.isDebugEnabled()) this.logger.debug(String.valueOf(o), t);
       }
   
       /**
        * @see org.apache.commons.logging.Log#debug(java.lang.Object)
        */
       public void debug(Object o) {
  -        if (this.logger.isDebugEnabled()) this.logger.debug(o.toString());
  +        if (this.logger.isDebugEnabled()) this.logger.debug(String.valueOf(o));
       }
   
       /**
        * @see org.apache.commons.logging.Log#error(java.lang.Object, java.lang.Throwable)
        */
       public void error(Object o, Throwable t) {
  -        if (this.logger.isErrorEnabled()) this.logger.error(o.toString(), t);
  +        if (this.logger.isErrorEnabled()) this.logger.error(String.valueOf(o), t);
       }
   
       /**
        * @see org.apache.commons.logging.Log#error(java.lang.Object)
        */
       public void error(Object o) {
  -        if (this.logger.isErrorEnabled()) this.logger.error(o.toString());
  +        if (this.logger.isErrorEnabled()) this.logger.error(String.valueOf(o));
       }
   
       /**
        * @see org.apache.commons.logging.Log#fatal(java.lang.Object, java.lang.Throwable)
        */
       public void fatal(Object o, Throwable t) {
  -        if (this.logger.isFatalErrorEnabled()) this.logger.fatalError(o.toString(), t);
  +        if (this.logger.isFatalErrorEnabled()) this.logger.fatalError(String.valueOf(o),
t);
       }
   
       /**
        * @see org.apache.commons.logging.Log#fatal(java.lang.Object)
        */
       public void fatal(Object o) {
  -        if (this.logger.isFatalErrorEnabled()) this.logger.fatalError(o.toString());
  +        if (this.logger.isFatalErrorEnabled()) this.logger.fatalError(String.valueOf(o));
       }
   
       /**
        * @see org.apache.commons.logging.Log#info(java.lang.Object, java.lang.Throwable)
        */
       public void info(Object o, Throwable t) {
  -        if (this.logger.isInfoEnabled()) this.logger.info(o.toString(), t);
  +        if (this.logger.isInfoEnabled()) this.logger.info(String.valueOf(o), t);
       }
   
       /**
        * @see org.apache.commons.logging.Log#info(java.lang.Object)
        */
       public void info(Object o) {
  -        if (this.logger.isInfoEnabled()) this.logger.info(o.toString());
  +        if (this.logger.isInfoEnabled()) this.logger.info(String.valueOf(o));
       }
   
       /**
  @@ -206,28 +208,28 @@
        * @see org.apache.commons.logging.Log#trace(java.lang.Object, java.lang.Throwable)
        */
       public void trace(Object o, Throwable t) {
  -        if (this.logger.isDebugEnabled()) this.logger.debug(o.toString(), t);
  +        if (this.logger.isDebugEnabled()) this.logger.debug(String.valueOf(o), t);
       }
   
       /**
        * @see org.apache.commons.logging.Log#trace(java.lang.Object)
        */
       public void trace(Object o) {
  -        if (this.logger.isDebugEnabled()) this.logger.debug(o.toString());
  +        if (this.logger.isDebugEnabled()) this.logger.debug(String.valueOf(o));
       }
   
       /**
        * @see org.apache.commons.logging.Log#warn(java.lang.Object, java.lang.Throwable)
        */
       public void warn(Object o, Throwable t) {
  -        if (this.logger.isWarnEnabled()) this.logger.warn(o.toString(), t);
  +        if (this.logger.isWarnEnabled()) this.logger.warn(String.valueOf(o), t);
       }
   
       /**
        * @see org.apache.commons.logging.Log#warn(java.lang.Object)
        */
       public void warn(Object o) {
  -        if (this.logger.isWarnEnabled()) this.logger.warn(o.toString());
  +        if (this.logger.isWarnEnabled()) this.logger.warn(String.valueOf(o));
       }
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message