craigmcc    01/08/15 09:48:56

  Modified:    logging  PROPOSAL.html
               logging/src/java/org/apache/commons/logging Log.java
                        Log4JCategoryLog.java LogSource.java NoOpLog.java
                        SimpleLog.java
  Log:
  Tweak the property names this layer looks for to be prefixed with
  "org.apache.commons.logging" instead of "httpclient".  Add a couple of
  Javadoc comments while I'm at it.
  
  Revision  Changes    Path
  1.4       +1 -0      jakarta-commons-sandbox/logging/PROPOSAL.html
  
  Index: PROPOSAL.html
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/logging/PROPOSAL.html,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PROPOSAL.html     2001/08/09 14:56:44     1.3
  +++ PROPOSAL.html     2001/08/15 16:48:56     1.4
  @@ -78,6 +78,7 @@
   <ul>
     <li>Morgan Delagrange</li>
     <li>Rodney Waldhoff</li>
  +  <li>Craig McClanahan</li>
   </ul>
   
   </body>
  
  
  
  1.5       +6 -2      
jakarta-commons-sandbox/logging/src/java/org/apache/commons/logging/Log.java
  
  Index: Log.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/logging/src/java/org/apache/commons/logging/Log.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Log.java  2001/08/08 20:35:22     1.4
  +++ Log.java  2001/08/15 16:48:56     1.5
  @@ -9,9 +9,13 @@
   package org.apache.commons.logging;
   
   /**
  - * A simple logging interface abstracting log4j.
  + * A simple logging interface abstracting logging APIs.  In order to be
  + * instantiated successfully by {@link LogFactory}, classes that implement
  + * this interface must have a constructor that takes a single String
  + * parameter representing the "name" of this Log.
  + *
    * @author Rod Waldhoff
  - * @version $Id: Log.java,v 1.4 2001/08/08 20:35:22 morgand Exp $
  + * @version $Id: Log.java,v 1.5 2001/08/15 16:48:56 craigmcc Exp $
    */
   public interface Log {
       public void debug(Object message);
  
  
  
  1.5       +4 -1      
jakarta-commons-sandbox/logging/src/java/org/apache/commons/logging/Log4JCategoryLog.java
  
  Index: Log4JCategoryLog.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/logging/src/java/org/apache/commons/logging/Log4JCategoryLog.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Log4JCategoryLog.java     2001/08/08 20:35:22     1.4
  +++ Log4JCategoryLog.java     2001/08/15 16:48:56     1.5
  @@ -12,8 +12,11 @@
   import org.apache.log4j.Priority;
   
   /**
  + * Implementation of {@link Log} that maps directly to a Log4J
  + * <strong>Category</strong>.
  + *
    * @author Rod Waldhoff
  - * @version $Id: Log4JCategoryLog.java,v 1.4 2001/08/08 20:35:22 morgand Exp $
  + * @version $Id: Log4JCategoryLog.java,v 1.5 2001/08/15 16:48:56 craigmcc Exp $
    */
   public class Log4JCategoryLog  implements Log {
       Category _category = null;
  
  
  
  1.3       +8 -4      
jakarta-commons-sandbox/logging/src/java/org/apache/commons/logging/LogSource.java
  
  Index: LogSource.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/logging/src/java/org/apache/commons/logging/LogSource.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LogSource.java    2001/08/08 20:35:22     1.2
  +++ LogSource.java    2001/08/15 16:48:56     1.3
  @@ -12,8 +12,10 @@
   import java.lang.reflect.Constructor;
   
   /**
  + * Factory for creating {@link Log} instances.
  + *
    * @author Rod Waldhoff
  - * @version $Id: LogSource.java,v 1.2 2001/08/08 20:35:22 morgand Exp $
  + * @version $Id: LogSource.java,v 1.3 2001/08/15 16:48:56 craigmcc Exp $
    */
   public class LogSource {
       static protected HashMap _logs = new HashMap();
  @@ -52,8 +54,8 @@
        * <p>
        * The specific {@link Log} implementation returned
        * is determined by the value of the
  -     * <tt>httpclient.log</tt> property.
  -     * The value of <tt>httpclient.log</tt> may be set to
  +     * <tt>org.apache.commons.logging.log</tt> property.
  +     * The value of <tt>org.apache.commons.logging.log</tt> may be set to
        * the fully specified name of a class that implements
        * the {@link Log} interface.  This class must also
        * have a public constructor that takes a single
  @@ -71,7 +73,9 @@
        */
       static public Log makeNewLogInstance(String name) {
           Log log = null;
  -        String logclassname = 
System.getProperty("httpclient.log","org.apache.commons.httpclient.log.NoOpLog");
  +        String logclassname =
  +            System.getProperty("org.apache.commoons.logging.log",
  +                               "org.apache.commons.logging.NoOpLog");
           try {
               Class logclass = Class.forName(logclassname);
               Class[] argtypes = new Class[1];
  
  
  
  1.5       +3 -1      
jakarta-commons-sandbox/logging/src/java/org/apache/commons/logging/NoOpLog.java
  
  Index: NoOpLog.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/logging/src/java/org/apache/commons/logging/NoOpLog.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- NoOpLog.java      2001/08/08 20:35:22     1.4
  +++ NoOpLog.java      2001/08/15 16:48:56     1.5
  @@ -9,8 +9,10 @@
   package org.apache.commons.logging;
   
   /**
  + * Default implementation of Log that throws away all messages.
  + *
    * @author Rod Waldhoff
  - * @version $Id: NoOpLog.java,v 1.4 2001/08/08 20:35:22 morgand Exp $
  + * @version $Id: NoOpLog.java,v 1.5 2001/08/15 16:48:56 craigmcc Exp $
    */
   public final class NoOpLog implements Log {
       public NoOpLog() { }
  
  
  
  1.5       +13 -10    
jakarta-commons-sandbox/logging/src/java/org/apache/commons/logging/SimpleLog.java
  
  Index: SimpleLog.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/logging/src/java/org/apache/commons/logging/SimpleLog.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SimpleLog.java    2001/08/08 20:35:22     1.4
  +++ SimpleLog.java    2001/08/15 16:48:56     1.5
  @@ -17,26 +17,29 @@
   
   /**
    * @author Rod Waldhoff
  - * @version $Id: SimpleLog.java,v 1.4 2001/08/08 20:35:22 morgand Exp $
  + * @version $Id: SimpleLog.java,v 1.5 2001/08/15 16:48:56 craigmcc Exp $
    */
   public class SimpleLog implements Log {
  +    static protected final String _prefix =
  +        "org.apache.commons.logging.simplelog.";
       static protected final Properties _simplelogProps = new Properties();
       static protected boolean _showlogname = false;
       static protected boolean _showtime = false;
       static protected DateFormat _df = null;
   
       static {
  -        // add all system props that start with "httpclient."
  +        // add all system props that start with the specified prefix
           Enumeration enum = System.getProperties().propertyNames();
           while(enum.hasMoreElements()) {
               String name = (String)(enum.nextElement());
  -            if(null != name && name.startsWith("httpclient.")) {
  +            if(null != name && name.startsWith(_prefix)) {
                   _simplelogProps.setProperty(name,System.getProperty(name));
               }
           }
   
           // add props from the resource simplelog.properties
  -        InputStream in = 
ClassLoader.getSystemResourceAsStream("simplelog.properties");
  +        InputStream in =
  +            ClassLoader.getSystemResourceAsStream("simplelog.properties");
           if(null != in) {
               try {
                   _simplelogProps.load(in);
  @@ -49,10 +52,10 @@
           } catch(Throwable t) {
               // ignored
           }
  -        _showlogname = 
"true".equalsIgnoreCase(_simplelogProps.getProperty("httpclient.simplelog.showlogname","true"));
  -        _showtime = 
"true".equalsIgnoreCase(_simplelogProps.getProperty("httpclient.simplelog.showdate","true"));
  +        _showlogname = "true".equalsIgnoreCase(_simplelogProps.getProperty(_prefix 
+ "showlogname","true"));
  +        _showtime = "true".equalsIgnoreCase(_simplelogProps.getProperty(_prefix + 
"showdate","true"));
           if(_showtime) {
  -            _df = new 
SimpleDateFormat(_simplelogProps.getProperty("httpclient.simplelog.dateformat","yyyy/MM/dd
 HH:mm:ss:SSS zzz"));
  +            _df = new SimpleDateFormat(_simplelogProps.getProperty(_prefix + 
"dateformat","yyyy/MM/dd HH:mm:ss:SSS zzz"));
           }
       }
   
  @@ -68,15 +71,15 @@
       public SimpleLog(String name) {
           _name = name;
   
  -        String lvl = _simplelogProps.getProperty("httpclient.simplelog.log." + 
_name);
  +        String lvl = _simplelogProps.getProperty(_prefix + "log." + _name);
           int i = String.valueOf(name).lastIndexOf(".");
           while(null == lvl && i > -1) {
               name = name.substring(0,i);
  -            lvl = _simplelogProps.getProperty("httpclient.simplelog.log." + name);
  +            lvl = _simplelogProps.getProperty(_prefix + "log." + name);
               i = String.valueOf(name).lastIndexOf(".");
           }
           if(null == lvl) {
  -            lvl =  _simplelogProps.getProperty("httpclient.simplelog.defaultlog");
  +            lvl =  _simplelogProps.getProperty(_prefix + "defaultlog");
           }
   
           if("debug".equalsIgnoreCase(lvl)) {
  
  
  

Reply via email to