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-sandbox/betwixt/src/java/org/apache/commons/betwixt/io BeanWriter.java
Date Wed, 19 Dec 2001 20:15:02 GMT
rdonkin     01/12/19 12:15:02

  Modified:    betwixt/src/java/org/apache/commons/betwixt/io
                        BeanWriter.java
  Log:
  Added logging using org.apache.commons.logging.Log
  
  Revision  Changes    Path
  1.9       +28 -3     jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/io/BeanWriter.java
  
  Index: BeanWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/io/BeanWriter.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- BeanWriter.java	2001/12/18 19:54:17	1.8
  +++ BeanWriter.java	2001/12/19 20:15:02	1.9
  @@ -5,7 +5,7 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    * 
  - * $Id: BeanWriter.java,v 1.8 2001/12/18 19:54:17 rdonkin Exp $
  + * $Id: BeanWriter.java,v 1.9 2001/12/19 20:15:02 rdonkin Exp $
    */
   package org.apache.commons.betwixt.io;
   
  @@ -17,6 +17,9 @@
   import java.io.Writer;
   import java.util.Iterator;
   
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
  +
   import org.apache.commons.betwixt.AttributeDescriptor;
   import org.apache.commons.betwixt.ElementDescriptor;
   import org.apache.commons.betwixt.XMLBeanInfo;
  @@ -24,6 +27,7 @@
   import org.apache.commons.betwixt.expression.Context;
   import org.apache.commons.betwixt.expression.Expression;
   
  +
   /** <p><code>BeanWriter</code> output beans as XML.</p>
     * The output for each bean is an xml fragment
     * (rather than a well-formed xml-document).
  @@ -42,7 +46,7 @@
     * The indent string used is set by {@link #setIndent}.
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.8 $
  +  * @version $Revision: 1.9 $
     */
   public class BeanWriter {
   
  @@ -58,6 +62,8 @@
       private int indentLevel;
       /** should we flush after writing bean */
       private boolean autoFlush;
  +    /** Log used for logging (Doh!) */
  +    private final Log log = LogSource.makeNewLogInstance("org.apache.commons.betwixt.BeanWriter");
       
       /**
        * <p> Constructor uses <code>System.out</code> for output.</p>
  @@ -93,6 +99,7 @@
        * @param bean write out representation of this bean
        */
       public void write(Object bean) throws IOException, IntrospectionException  {
  +        log.debug("Writing bean graph...");
           XMLBeanInfo beanInfo = introspector.introspect( bean );
           if ( beanInfo != null ) {
               ElementDescriptor elementDescriptor = beanInfo.getElementDescriptor();
  @@ -105,6 +112,7 @@
           if ( autoFlush ) {
               writer.flush();
           }
  +        log.debug("Finished writing bean graph.");
       }
       
       /**
  @@ -160,7 +168,24 @@
           this.introspector = introspector;
       }
   
  -    
  +    /**
  +     * <p> Get the current level for logging. </p>
  +     *
  +     * @return a <code>org.apache.commons.logging.Log</code> level constant
  +     */ 
  +    public int getLogLevel() {
  +        return log.getLevel();
  +    }
  +
  +    /**
  +     * <p> Set the current logging level. </p>
  +     *
  +     * @param level a <code>org.apache.commons.logging.Log</code> level constant
  +     */ 
  +    public void setLogLevel(int level) {
  +        log.setLevel(level);
  +    }
  +        
       // Implementation methods
       //-------------------------------------------------------------------------    
       
  
  
  

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


Mime
View raw message