commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject cvs commit: jakarta-commons/logging/src/java/org/apache/commons/logging AbstractLog.java Jdk14Logger.java Log.java Log4JCategoryLog.java LogKitLogger.java LogSource.java NoOpLog.java SimpleLog.java
Date Thu, 17 Jan 2002 01:47:49 GMT
craigmcc    02/01/16 17:47:49

  Modified:    logging/src/java/org/apache/commons/logging AbstractLog.java
                        Jdk14Logger.java Log.java Log4JCategoryLog.java
                        LogKitLogger.java LogSource.java NoOpLog.java
                        SimpleLog.java
  Log:
  Implement the agreed-upon API changes for the commons-logging package.
  If the changes are too radical, I tagged things with "before_clean_up" to make
  it easy to go back.
  
  Revision  Changes    Path
  1.2       +166 -49   jakarta-commons/logging/src/java/org/apache/commons/logging/AbstractLog.java
  
  Index: AbstractLog.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/AbstractLog.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractLog.java	3 Jan 2002 18:52:25 -0000	1.1
  +++ AbstractLog.java	17 Jan 2002 01:47:49 -0000	1.2
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/AbstractLog.java,v
1.1 2002/01/03 18:52:25 rdonkin Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/01/03 18:52:25 $
  + * $Header: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/AbstractLog.java,v
1.2 2002/01/17 01:47:49 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/01/17 01:47:49 $
    *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -65,27 +65,30 @@
   
   /**
     * <p> This is an abstract implementation of the <code>Log</code> interface.
  -  * It provides the following common services for the actual concrete implementations:
  +  * It provides the following common services for the actual concrete
  +  * implementations:
     * 
     * <h4> Log Level Property </h4> 
     * <p> Property getter and setter for log levels. </p>
     * 
     * <h4> Log Level Enforcement</h4>
  -  * <p> The current log level is checked and then the message will be passed onto
the
  -  * subclass implementation if the level is currently enabled. </p>
  +  * <p> The current log level is checked and then the message will be passed
  +  * onto the subclass implementation if the level is currently enabled. </p>
     *
     * @author Robert Burrell Donkin
  -  * @version $Revision: 1.1 $
  +  * @version $Revision: 1.2 $
    */
   public abstract class AbstractLog implements Log {
   
  -    // --------------------------------------------------------- Attributes
  +
  +    // ------------------------------------------------------------- Attributes
       
       /** Default log level is currently <code>OFF</code> */
       private int currentLogLevel = Log.OFF;
   
   
  -    // --------------------------------------------------------- Properties
  +    // ------------------------------------------------------------- Properties
  +
   
       /**
        * <p> Set logging level. </p> 
  @@ -97,6 +100,7 @@
           this.currentLogLevel = currentLogLevel;
       }
       
  +
       /**
        * <p> Get logging level. </p> 
        */
  @@ -105,44 +109,9 @@
           return currentLogLevel;
       }
       
  -    /**
  -     * <p> Are debug messages currently enabled? </p>
  -     *
  -     * <p> This allows expensive operations such as <code>String</code>
concatination
  -     * to be avoided when the message will be ignored by the logger. </p>
  -     *
  -     * <p> This implementation checks that the log level is debug or lower.
  -     * If it is, then it passes the request onto {@link #isDebugEnabledImpl}.
  -     */
  -    public final boolean isDebugEnabled() {
  -    
  -        if (isLevelEnabled(Log.DEBUG)) {
  -            return isDebugEnabledImpl();
  -        }
  -        
  -        return false;
  -    }
  -    
  -    /**
  -     * <p> Are info messages currently enabled? </p>
  -     *
  -     * <p> This allows expensive operations such as <code>String</code>
concatination
  -     * to be avoided when the message will be ignored by the logger. </p>
  -     *
  -     * <p> This implementation checks that the log level is debug or lower.
  -     * If it is, then it passes the request onto {@link #isInfoEnabledImpl}.
  -     */
  -    public final boolean isInfoEnabled() {
  -    
  -        if (isLevelEnabled(Log.INFO)) {
  -            return isInfoEnabledImpl();
  -        }
  -        
  -        return false;
  -    }  
   
  -    
  -    // --------------------------------------------------------- Logging Methods
  +    // -------------------------------------------------------- Logging Methods
  +
   
       /**
        * <p> Log a message with debug log level.</p> 
  @@ -157,6 +126,7 @@
           }
       }
       
  +
       /**
        * <p> Log an error with debug log level.</p> 
        *
  @@ -170,6 +140,7 @@
           }
       }
   
  +
       /**
        * <p> Log a message with info log level.</p> 
        *
  @@ -183,6 +154,7 @@
           }
       }
       
  +
       /**
        * <p> Log an error with info log level.</p> 
        *
  @@ -196,6 +168,7 @@
           }
       }
       
  +
       /**
        * <p> Log a message with warn log level.</p> 
        *
  @@ -209,6 +182,7 @@
           }
       }
   
  +
       /**
        * <p> Log an error with warn log level.</p> 
        *
  @@ -222,6 +196,7 @@
           }
       }
       
  +
       /**
        * <p> Log a message with error log level.</p> 
        *
  @@ -235,6 +210,7 @@
           }
       }
       
  +
       /**
        * <p> Log an error with error log level.</p> 
        *
  @@ -248,6 +224,7 @@
           }
       }
       
  +
       /**
        * <p> Log a message with fatal log level.</p> 
        *
  @@ -261,6 +238,7 @@
           }
       }
   
  +
       /**
        * <p> Log an error with fatal log level.</p> 
        *
  @@ -275,8 +253,107 @@
       }
     
       
  +    /**
  +     * <p> Are debug messages currently enabled? </p>
  +     *
  +     * <p> This allows expensive operations such as <code>String</code>
  +     * concatenation to be avoided when the message will be ignored by the
  +     * logger. </p>
  +     *
  +     * <p> This implementation checks that the log level is debug or lower.
  +     * If it is, then it passes the request onto {@link #isDebugEnabledImpl}.
  +     */
  +    public final boolean isDebugEnabled() {
  +    
  +        if (isLevelEnabled(Log.DEBUG)) {
  +            return isDebugEnabledImpl();
  +        }
  +        
  +        return false;
  +    }
  +    
  +
  +    /**
  +     * <p> Are error messages currently enabled? </p>
  +     *
  +     * <p> This allows expensive operations such as <code>String</code>
  +     * concatenation to be avoided when the message will be ignored by the
  +     * logger. </p>
  +     *
  +     * <p> This implementation checks that the log level is error or lower.
  +     * If it is, then it passes the request onto {@link #isErrorEnabledImpl}.
  +     */
  +    public final boolean isErrorEnabled() {
  +    
  +        if (isLevelEnabled(Log.ERROR)) {
  +            return isErrorEnabledImpl();
  +        }
  +        
  +        return false;
  +    }
  +    
  +
  +    /**
  +     * <p> Are fatal messages currently enabled? </p>
  +     *
  +     * <p> This allows expensive operations such as <code>String</code>
  +     * concatenation to be avoided when the message will be ignored by the
  +     * logger. </p>
  +     *
  +     * <p> This implementation checks that the log level is fatal or lower.
  +     * If it is, then it passes the request onto {@link #isFatalEnabledImpl}.
  +     */
  +    public final boolean isFatalEnabled() {
       
  -    // --------------------------------------------------------- Decorated Implementation
  +        if (isLevelEnabled(Log.FATAL)) {
  +            return isFatalEnabledImpl();
  +        }
  +        
  +        return false;
  +    }
  +    
  +
  +    /**
  +     * <p> Are info messages currently enabled? </p>
  +     *
  +     * <p> This allows expensive operations such as <code>String</code>
  +     * concatenation to be avoided when the message will be ignored by the
  +     * logger. </p>
  +     *
  +     * <p> This implementation checks that the log level is info or lower.
  +     * If it is, then it passes the request onto {@link #isInfoEnabledImpl}.
  +     */
  +    public final boolean isInfoEnabled() {
  +    
  +        if (isLevelEnabled(Log.INFO)) {
  +            return isInfoEnabledImpl();
  +        }
  +        
  +        return false;
  +    }  
  +
  +    
  +    /**
  +     * <p> Are warn messages currently enabled? </p>
  +     *
  +     * <p> This allows expensive operations such as <code>String</code>
  +     * concatenation to be avoided when the message will be ignored by the
  +     * logger. </p>
  +     *
  +     * <p> This implementation checks that the log level is warn or lower.
  +     * If it is, then it passes the request onto {@link #isWarnEnabledImpl}.
  +     */
  +    public final boolean isWarnEnabled() {
  +    
  +        if (isLevelEnabled(Log.WARN)) {
  +            return isWarnEnabledImpl();
  +        }
  +        
  +        return false;
  +    }
  +    
  +
  +    // ----------------------------------------------- Decorated Implementation
    
       /**
        * <p> [OVERRIDE] Log a message with debug log level. 
  @@ -356,6 +433,30 @@
       }
   
       /**
  +     * <p> Are error messages currently enabled? </p>
  +     *
  +     * <p> Subclasses should override this method if their logger provides 
  +     * a special implementation. </p>
  +     *
  +     * @return true
  +     */
  +    protected boolean isErrorEnabledImpl() {
  +        return true;
  +    }
  +
  +    /**
  +     * <p> Are fatal messages currently enabled? </p>
  +     *
  +     * <p> Subclasses should override this method if their logger provides 
  +     * a special implementation. </p>
  +     *
  +     * @return true
  +     */
  +    protected boolean isFatalEnabledImpl() {
  +        return true;
  +    }
  +
  +    /**
        * <p> Are info messages currently enabled? </p>
        *
        * <p> Subclasses should override this method if their logger provides 
  @@ -367,9 +468,22 @@
           return true;
       }
   
  +    /**
  +     * <p> Are warn messages currently enabled? </p>
  +     *
  +     * <p> Subclasses should override this method if their logger provides 
  +     * a special implementation. </p>
  +     *
  +     * @return true
  +     */
  +    protected boolean isWarnEnabledImpl() {
  +        return true;
  +    }
  +
       
       
  -    // --------------------------------------------------------- Implementation Methods
  +    // ------------------------------------------------- Implementation Methods
  +
   
       /**
        * Is the given log level currently enabled?
  @@ -377,7 +491,10 @@
        * @param logLevel is this level enabled?
        */
       protected boolean isLevelEnabled(int logLevel) {
  -        // log level are numerically ordered so can use simple numeric comparison
  +        // log level are numerically ordered so can use simple numeric
  +        // comparison
           return (logLevel >= currentLogLevel);
       }
  +
  +
   }
  
  
  
  1.2       +28 -53    jakarta-commons/logging/src/java/org/apache/commons/logging/Jdk14Logger.java
  
  Index: Jdk14Logger.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/Jdk14Logger.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Jdk14Logger.java	5 Jan 2002 22:40:40 -0000	1.1
  +++ Jdk14Logger.java	17 Jan 2002 01:47:49 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/Jdk14Logger.java,v
1.1 2002/01/05 22:40:40 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/01/05 22:40:40 $
  + * $Header: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/Jdk14Logger.java,v
1.2 2002/01/17 01:47:49 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/01/17 01:47:49 $
    *
    * ====================================================================
    *
  @@ -73,10 +73,10 @@
    * introduced in the Merlin release (JDK 1.4).</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2002/01/05 22:40:40 $
  + * @version $Revision: 1.2 $ $Date: 2002/01/17 01:47:49 $
    */
   
  -public class Jdk14Logger implements Log {
  +public final class Jdk14Logger implements Log {
   
   
       // ----------------------------------------------------------- Constructors
  @@ -169,35 +169,6 @@
   
   
       /**
  -     * Return the current logging level.
  -     */
  -    public int getLevel() {
  -
  -        Level level = logger.getLevel();
  -        if (level == Level.ALL) {
  -            return (ALL);
  -        } else if (level == Level.SEVERE) {
  -            return (ERROR);
  -        } else if (level == Level.WARNING) {
  -            return (WARN);
  -        } else if (level == Level.INFO) {
  -            return (INFO);
  -        } else if (level == Level.CONFIG) {
  -            return (DEBUG);
  -        } else if (level == Level.FINE) {
  -            return (DEBUG);
  -        } else if (level == Level.FINER) {
  -            return (DEBUG);
  -        } else if (level == Level.FINEST) {
  -            return (DEBUG);
  -        } else {
  -            return (OFF);
  -        }
  -
  -    }
  -
  -
  -    /**
        * Return the native Logger instance we are using.
        */
       public Logger getLogger() {
  @@ -238,6 +209,26 @@
   
   
       /**
  +     * Is error logging currently enabled?
  +     */
  +    public boolean isErrorEnabled() {
  +
  +        return (logger.isLoggable(Level.SEVERE));
  +
  +    }
  +
  +
  +    /**
  +     * Is fatal logging currently enabled?
  +     */
  +    public boolean isFatalEnabled() {
  +
  +        return (logger.isLoggable(Level.SEVERE));
  +
  +    }
  +
  +
  +    /**
        * Is info logging currently enabled?
        */
       public boolean isInfoEnabled() {
  @@ -248,27 +239,11 @@
   
   
       /**
  -     * Set the new logging level.
  -     *
  -     * @param level New logging level
  +     * Is warning logging currently enabled?
        */
  -    public void setLevel(int level) {
  +    public boolean isWarnEnabled() {
   
  -        if (level == OFF) {
  -            logger.setLevel(Level.OFF);
  -        } else if (level >= FATAL) {
  -            logger.setLevel(Level.SEVERE);
  -        } else if (level >= ERROR) {
  -            logger.setLevel(Level.SEVERE);
  -        } else if (level >= WARN) {
  -            logger.setLevel(Level.WARNING);
  -        } else if (level >= INFO) {
  -            logger.setLevel(Level.INFO);
  -        } else if (level >= DEBUG) {
  -            logger.setLevel(Level.FINEST);
  -        } else if (level >= ALL) {
  -            logger.setLevel(Level.ALL);
  -        }
  +        return (logger.isLoggable(Level.WARNING));
   
       }
   
  
  
  
  1.9       +50 -19    jakarta-commons/logging/src/java/org/apache/commons/logging/Log.java
  
  Index: Log.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/Log.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Log.java	3 Jan 2002 18:54:29 -0000	1.8
  +++ Log.java	17 Jan 2002 01:47:49 -0000	1.9
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/Log.java,v
1.8 2002/01/03 18:54:29 rdonkin Exp $
  - * $Revision: 1.8 $
  - * $Date: 2002/01/03 18:54:29 $
  + * $Header: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/Log.java,v
1.9 2002/01/17 01:47:49 craigmcc Exp $
  + * $Revision: 1.9 $
  + * $Date: 2002/01/17 01:47:49 $
    *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -63,10 +63,10 @@
   package org.apache.commons.logging;
   
   /**
  - * <p> A simple logging interface abstracting logging APIs.  In order to be
  + * <p>A simple logging interface abstracting logging APIs.  In order to be
    * instantiated successfully by {@link LogSource}, classes that implement
    * this interface must have a constructor that takes a single String
  - * parameter representing the "name" of this Log. </p>
  + * parameter representing the "name" of this Log.</p>
    *
    * <p> The log level determines whether a particular message
    * should be passed to the logging implementation.
  @@ -74,15 +74,21 @@
    * For example, if the log level is <code>warn</code> 
    * then the message passed to {@link #error} will be passed to the logging 
    * implementation but if the log level is <code>fatal</code> or higher
  - * then the message will not.
  + * then the message will not.</p>
  + *
  + * <p>The logging level constants are provided for the convenience of
  + * {@link Log} implementations that wish to support dynamic changes in the
  + * logging level configuration.  However, configuration will generally be done
  + * external to the Logging APIs, through whatever mechanism is supported by
  + * the underlying logging implementation in use.</p>
    *
    * @author Rod Waldhoff
  - * @version $Id: Log.java,v 1.8 2002/01/03 18:54:29 rdonkin Exp $
  + * @version $Id: Log.java,v 1.9 2002/01/17 01:47:49 craigmcc Exp $
    */
   public interface Log {
   
   
  -    // --------------------------------------------------------- Log Level Constants
  +    // ---------------------------------------------------- Log Level Constants
       
       /** All logging level. */
       public static final int ALL  = Integer.MIN_VALUE;
  @@ -100,8 +106,9 @@
       public static final int OFF  = Integer.MAX_VALUE;
       
       
  -    // --------------------------------------------------------- Logging Properties
  +    // ----------------------------------------------------- Logging Properties
       
  +
       /**
        * <p> Is debug logging currently enabled? </p>
        *
  @@ -111,37 +118,56 @@
        */
       public boolean isDebugEnabled();
       
  +
       /**
  -     * <p> Is info logging currently enabled? </p>
  +     * <p> Is error logging currently enabled? </p>
        *
        * <p> Call this method to prevent having to perform expensive operations
        * (for example, <code>String</code> concatination)
  -     * when the log level is more than debug. </p> 
  +     * when the log level is more than error. </p> 
        */
  -    public boolean isInfoEnabled();
  +    public boolean isErrorEnabled();
  +    
   
  +    /**
  +     * <p> Is fatal logging currently enabled? </p>
  +     *
  +     * <p> Call this method to prevent having to perform expensive operations
  +     * (for example, <code>String</code> concatination)
  +     * when the log level is more than fatal. </p> 
  +     */
  +    public boolean isFatalEnabled();
       
  +
       /**
  -     * <p> Set logging level. </p> 
  +     * <p> Is info logging currently enabled? </p>
        *
  -     * @param level new logging level
  +     * <p> Call this method to prevent having to perform expensive operations
  +     * (for example, <code>String</code> concatination)
  +     * when the log level is more than info. </p> 
        */
  -    public void setLevel(int level);
  +    public boolean isInfoEnabled();
  +
       
       /**
  -     * <p> Get logging level. </p> 
  +     * <p> Is warning logging currently enabled? </p>
  +     *
  +     * <p> Call this method to prevent having to perform expensive operations
  +     * (for example, <code>String</code> concatination)
  +     * when the log level is more than warning. </p> 
        */
  -    public int getLevel();
  +    public boolean isWarnEnabled();
   
       
  +    // -------------------------------------------------------- Logging Methods
   
  -    // --------------------------------------------------------- Logging Methods
   
       /**
        * <p> Log a message with debug log level </p> 
        */
       public void debug(Object message);
       
  +
       /**
        * <p> Log an error with debug log level </p> 
        */
  @@ -153,6 +179,7 @@
        */
       public void info(Object message);
       
  +
       /**
        * <p> Log an error with info log level </p> 
        */
  @@ -164,6 +191,7 @@
        */
       public void warn(Object message);
   
  +
       /**
        * <p> Log an error with warn log level </p> 
        */
  @@ -175,6 +203,7 @@
        */
       public void error(Object message);
   
  +
       /**
        * <p> Log an error with error log level </p> 
        */
  @@ -186,9 +215,11 @@
        */
       public void fatal(Object message);
   
  +
       /**
        * <p> Log an error with fatal log level </p> 
        */
       public void fatal(Object message, Throwable t);
  +
   
   }
  
  
  
  1.8       +76 -43    jakarta-commons/logging/src/java/org/apache/commons/logging/Log4JCategoryLog.java
  
  Index: Log4JCategoryLog.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/Log4JCategoryLog.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Log4JCategoryLog.java	3 Jan 2002 18:59:57 -0000	1.7
  +++ Log4JCategoryLog.java	17 Jan 2002 01:47:49 -0000	1.8
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/Log4JCategoryLog.java,v
1.7 2002/01/03 18:59:57 rdonkin Exp $
  - * $Revision: 1.7 $
  - * $Date: 2002/01/03 18:59:57 $
  + * $Header: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/Log4JCategoryLog.java,v
1.8 2002/01/17 01:47:49 craigmcc Exp $
  + * $Revision: 1.8 $
  + * $Date: 2002/01/17 01:47:49 $
    *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -71,120 +71,153 @@
    * Category instances should be done in the usual manner, as outlined in
    * the Log4J documentation.</p>
    *
  - * <p> Log level management is now independent of the Log4J configuration.
  - * Log4J will not be called unless the log level is currently enabled. </p>
  - *
    * @author Rod Waldhoff
    * @author Robert Burrell Donkin
    *
  - * @version $Id: Log4JCategoryLog.java,v 1.7 2002/01/03 18:59:57 rdonkin Exp $
  + * @version $Id: Log4JCategoryLog.java,v 1.8 2002/01/17 01:47:49 craigmcc Exp $
    */
  -public final class Log4JCategoryLog  extends AbstractLog {
  +public final class Log4JCategoryLog implements Log {
       
  -    // --------------------------------------------------------- Attributes
  +
  +    // ------------------------------------------------------------- Attributes
       
  -    /** Log to this category */
  -    Category _category = null;
   
  +    /** Log to this category */
  +    Category category = null;
   
   
  -    // --------------------------------------------------------- Constructor
  +    // ------------------------------------------------------------ Constructor
       
       
       /** 
        * Base constructor 
        */
       public Log4JCategoryLog(String name) {
  -        // the default log level for log4j should be ALL
  -        // so that control of logging is delegated to Log4J.
  -        // of course, this can be override programmatically for a particular log instance.
  -        setLevel(Log.ALL);
  -        _category = Category.getInstance(name);
  +        category = Category.getInstance(name);
       }
   
  -    // --------------------------------------------------------- Implmentation
  +
  +    // ---------------------------------------------------------- Implmentation
  +
   
       /**
        * Simply call log4j category.
        */
  -    protected final void debugImpl(Object message) {
  -        _category.debug(message);
  +    public void debug(Object message) {
  +        category.debug(message);
       }
   
  +
       /**
        * Simply call log4j category.
        */
  -    protected final void debugImpl(Object message, Throwable t) {
  -        _category.debug(message,t);
  +    public void debug(Object message, Throwable t) {
  +        category.debug(message,t);
       }
   
  +
       /**
        * Simply call log4j category.
        */
  -    protected final void infoImpl(Object message) {
  -        _category.info(message);
  +    public void info(Object message) {
  +        category.info(message);
       }
   
  +
       /**
        * Simply call log4j category.
        */
  -    protected final void infoImpl(Object message, Throwable t) {
  -        _category.info(message,t);
  +    public void info(Object message, Throwable t) {
  +        category.info(message,t);
       }
   
  +
       /**
        * Simply call log4j category.
        */
  -    protected final void warnImpl(Object message) {
  -        _category.warn(message);
  +    public void warn(Object message) {
  +        category.warn(message);
       }
  +
       
       /**
        * Simply call log4j category.
        */
  -    protected final void warnImpl(Object message, Throwable t) {
  -        _category.warn(message,t);
  +    public void warn(Object message, Throwable t) {
  +        category.warn(message,t);
       }
   
  +
       /**
        * Simply call log4j category.
        */
  -    protected final void errorImpl(Object message) {
  -        _category.error(message);
  +    public void error(Object message) {
  +        category.error(message);
       }
   
  +
       /**
        * Simply call log4j category.
        */
  -    protected final void errorImpl(Object message, Throwable t) {
  -        _category.error(message,t);
  +    public void error(Object message, Throwable t) {
  +        category.error(message,t);
       }
   
  +
       /**
        * Simply call log4j category.
        */
  -    protected final void fatalImpl(Object message) {
  -        _category.fatal(message);
  +    public void fatal(Object message) {
  +        category.fatal(message);
       }
   
  +
       /**
        * Simply call log4j category.
        */
  -    protected final void fatalImpl(Object message, Throwable t) {
  -        _category.fatal(message,t);
  +    public void fatal(Object message, Throwable t) {
  +        category.fatal(message,t);
       }
   
  +
       /**
        * Simply call log4j category.
        */
  -    protected final boolean isDebugEnabledImpl() {
  -        return _category.isDebugEnabled();
  +    public boolean isDebugEnabled() {
  +        return category.isDebugEnabled();
       }
   
  +
       /**
        * Simply call log4j category.
        */
  -    protected final boolean isInfoEnabledImpl() {
  -        return _category.isInfoEnabled();
  +    public boolean isErrorEnabled() {
  +        return category.isEnabledFor(Priority.ERROR);
       }
  +
  +
  +    /**
  +     * Simply call log4j category.
  +     */
  +    public boolean isFatalEnabled() {
  +        return category.isEnabledFor(Priority.FATAL);
  +    }
  +
  +
  +    /**
  +     * Simply call log4j category.
  +     */
  +    public boolean isInfoEnabled() {
  +        return category.isInfoEnabled();
  +    }
  +
  +
  +    /**
  +     * Simply call log4j category.
  +     */
  +    public boolean isWarnEnabled() {
  +        return category.isEnabledFor(Priority.WARN);
  +    }
  +
  +
   }
  
  
  
  1.2       +68 -24    jakarta-commons/logging/src/java/org/apache/commons/logging/LogKitLogger.java
  
  Index: LogKitLogger.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/LogKitLogger.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LogKitLogger.java	7 Jan 2002 23:06:10 -0000	1.1
  +++ LogKitLogger.java	17 Jan 2002 01:47:49 -0000	1.2
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/LogKitLogger.java,v
1.1 2002/01/07 23:06:10 rdonkin Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/01/07 23:06:10 $
  + * $Header: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/LogKitLogger.java,v
1.2 2002/01/17 01:47:49 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/01/17 01:47:49 $
    *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -70,20 +70,25 @@
    *
    * @author Robert Burrell Donkin
    *
  - * @version $Id: LogKitLogger.java,v 1.1 2002/01/07 23:06:10 rdonkin Exp $
  + * @version $Id: LogKitLogger.java,v 1.2 2002/01/17 01:47:49 craigmcc Exp $
    */
  -public class LogKitLogger extends AbstractLog {
   
  -    // --------------------------------------------------------- Attributes
  +public final class LogKitLogger implements Log {
  +
  +
  +    // ------------------------------------------------------------- Attributes
  +
   
       /** Logging goes to this <code>LogKit</code> logger */
       protected Logger logger = null;
   
   
  -    // --------------------------------------------------------- Constructor
  +    // ------------------------------------------------------------ Constructor
       
  +
       /**  
  -     * Constructor <code>LogKitLogger</code> which wrappers <code>LogKit</code>
category with given name.
  +     * Construct <code>LogKitLogger</code> which wraps the <code>LogKit</code>
  +     * logger with given name.
        * 
        * @param name log name
        */
  @@ -91,109 +96,148 @@
           logger = Hierarchy.getDefaultHierarchy().getLoggerFor(name);
       }
   
  -    // --------------------------------------------------------- Log Implementation
  +
  +    // ----------------------------------------------------- Log Implementation
  +
   
       /**
        * Log to <code>LogKit</code> logger.
        */
  -    protected final void debugImpl(Object message) {
  +    public void debug(Object message) {
           if (message != null) {
               logger.debug(message.toString());
           }
       }
   
  +
       /**
        * Log to <code>LogKit</code> logger.
        */
  -    protected final void debugImpl(Object message, Throwable t) {
  +    public void debug(Object message, Throwable t) {
           if (message != null) {
               logger.debug(message.toString(), t);
           }
       }
   
  +
       /**
        * Log to <code>LogKit</code> logger.
        */
  -    protected final void infoImpl(Object message) {
  +    public void info(Object message) {
           if (message != null) {
               logger.info(message.toString());
           }
       }
   
  +
       /**
        * Log to <code>LogKit</code> logger.
        */
  -    protected final void infoImpl(Object message, Throwable t) {
  +    public void info(Object message, Throwable t) {
           if (message != null) {
               logger.info(message.toString(), t);
           }
       }
   
  +
       /**
        * Log to <code>LogKit</code> logger.
        */
  -    protected final void warnImpl(Object message) {
  +    public void warn(Object message) {
           if (message != null) {
               logger.warn(message.toString());
           }
       }
       
  +
       /**
        * Log to <code>LogKit</code> logger.
        */
  -    protected final void warnImpl(Object message, Throwable t) {
  +    public void warn(Object message, Throwable t) {
           if (message != null) {
               logger.warn(message.toString(), t);
           }
       }
   
  +
       /**
        * Log to <code>LogKit</code> logger.
        */
  -    protected final void errorImpl(Object message) {
  +    public void error(Object message) {
           if (message != null) {
               logger.error(message.toString());
           }
       }
   
  +
       /**
        * Log to <code>LogKit</code> logger.
        */
  -    protected final void errorImpl(Object message, Throwable t) {
  +    public void error(Object message, Throwable t) {
           if (message != null) {
               logger.error(message.toString(), t);
           }
       }
   
  +
       /**
        * Log to <code>LogKit</code> logger.
        */
  -    protected final void fatalImpl(Object message) {
  +    public void fatal(Object message) {
           if (message != null) {
               logger.fatalError(message.toString());
           }
       }
   
  +
       /**
        * Log to <code>LogKit</code> logger.
        */
  -    protected final void fatalImpl(Object message, Throwable t) {
  +    public void fatal(Object message, Throwable t) {
           if (message != null) {
               logger.fatalError(message.toString(), t);
           }
       }
   
  +
  +    /**
  +     * Check that debug is enabled for <code>LogKit</code> logger.
  +     */       
  +    public boolean isDebugEnabled() {
  +        return logger.isDebugEnabled();
  +    }
  +
  +
  +    /**
  +     * Check that error is enabled for <code>LogKit</code> logger.
  +     */       
  +    public boolean isErrorEnabled() {
  +        return logger.isErrorEnabled();
  +    }
  +
  +
  +    /**
  +     * Check that fatal is enabled for <code>LogKit</code> logger.
  +     */       
  +    public boolean isFatalEnabled() {
  +        return logger.isFatalErrorEnabled();
  +    }
  +
  +
       /**
        * Check that info is enabled for <code>LogKit</code> logger.
        */    
  -    protected boolean isInfoEnabledImpl() {
  +    public boolean isInfoEnabled() {
           return logger.isInfoEnabled();
       }
   
  +
       /**
  -     * Check that debug is enabled for <code>LogKit</code> logger.
  +     * Check that warn is enabled for <code>LogKit</code> logger.
        */       
  -    protected boolean isDebugEnabledImpl() {
  -        return logger.isDebugEnabled();
  +    public boolean isWarnEnabled() {
  +        return logger.isWarnEnabled();
       }
  +
  +
   }
  
  
  
  1.9       +8 -16     jakarta-commons/logging/src/java/org/apache/commons/logging/LogSource.java
  
  Index: LogSource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/LogSource.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- LogSource.java	16 Jan 2002 00:54:51 -0000	1.8
  +++ LogSource.java	17 Jan 2002 01:47:49 -0000	1.9
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/LogSource.java,v
1.8 2002/01/16 00:54:51 craigmcc Exp $
  - * $Revision: 1.8 $
  - * $Date: 2002/01/16 00:54:51 $
  + * $Header: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/LogSource.java,v
1.9 2002/01/17 01:47:49 craigmcc Exp $
  + * $Revision: 1.9 $
  + * $Date: 2002/01/17 01:47:49 $
    *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -61,11 +61,13 @@
   
   package org.apache.commons.logging;
   
  +
   import java.util.HashMap;
   import java.lang.reflect.Constructor;
   import java.util.Iterator;
   import java.lang.reflect.InvocationTargetException;
   
  +
   /**
    * <p>Factory for creating {@link Log} instances.  Applications should call
    * the <code>makeNewLogInstance()</code> method to instantiate new instances
  @@ -92,7 +94,7 @@
    * </ul>
    *
    * @author Rod Waldhoff
  - * @version $Id: LogSource.java,v 1.8 2002/01/16 00:54:51 craigmcc Exp $
  + * @version $Id: LogSource.java,v 1.9 2002/01/17 01:47:49 craigmcc Exp $
    */
   public class LogSource {
   
  @@ -283,17 +285,6 @@
   
       }
   
  -    /**
  -     * Sets the log level for all {@link Log}s known
  -     * to me.
  -     */
  -    static public void setLevel(int level) {
  -        Iterator it = _logs.entrySet().iterator();
  -        while(it.hasNext()) {
  -            Log log = (Log)(it.next());
  -            log.setLevel(level);
  -        }
  -    }
   
       /**
        * Returns a {@link String} array containing the names of
  @@ -302,5 +293,6 @@
       static public String[] getLogNames() {
           return (String[])(_logs.keySet().toArray(new String[_logs.size()]));
       }
  +
   
   }
  
  
  
  1.8       +25 -11    jakarta-commons/logging/src/java/org/apache/commons/logging/NoOpLog.java
  
  Index: NoOpLog.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/NoOpLog.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- NoOpLog.java	3 Jan 2002 18:56:54 -0000	1.7
  +++ NoOpLog.java	17 Jan 2002 01:47:49 -0000	1.8
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/NoOpLog.java,v
1.7 2002/01/03 18:56:54 rdonkin Exp $
  - * $Revision: 1.7 $
  - * $Date: 2002/01/03 18:56:54 $
  + * $Header: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/NoOpLog.java,v
1.8 2002/01/17 01:47:49 craigmcc Exp $
  + * $Revision: 1.8 $
  + * $Date: 2002/01/17 01:47:49 $
    *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -67,7 +67,7 @@
    * configurable system properties are supported.</p>
    *
    * @author Rod Waldhoff
  - * @version $Id: NoOpLog.java,v 1.7 2002/01/03 18:56:54 rdonkin Exp $
  + * @version $Id: NoOpLog.java,v 1.8 2002/01/17 01:47:49 craigmcc Exp $
    */
   public final class NoOpLog implements Log {
   
  @@ -104,18 +104,32 @@
       public final boolean isDebugEnabled() { return false; }
       
       /** 
  +     * Error is never enabled. 
  +     *
  +     * @return false
  +     */
  +    public final boolean isErrorEnabled() { return false; }
  +    
  +    /** 
  +     * Fatal is never enabled. 
  +     *
  +     * @return false
  +     */
  +    public final boolean isFatalEnabled() { return false; }
  +    
  +    /** 
        * Info is never enabled. 
        *
        * @return false
        */
       public final boolean isInfoEnabled() { return false; }
   
  -    /** Do nothing */
  -    public final void setLevel(int level) { }
       /** 
  -     * Always return off.
  -     * 
  -     * @return <code>Log.OFF</code> 
  +     * Warning is never enabled. 
  +     *
  +     * @return false
        */
  -    public final int getLevel() { return Log.OFF; }
  +    public final boolean isWarnEnabled() { return false; }
  +
  +
   }
  
  
  
  1.8       +14 -11    jakarta-commons/logging/src/java/org/apache/commons/logging/SimpleLog.java
  
  Index: SimpleLog.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/SimpleLog.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SimpleLog.java	3 Jan 2002 19:00:19 -0000	1.7
  +++ SimpleLog.java	17 Jan 2002 01:47:49 -0000	1.8
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/SimpleLog.java,v
1.7 2002/01/03 19:00:19 rdonkin Exp $
  - * $Revision: 1.7 $
  - * $Date: 2002/01/03 19:00:19 $
  + * $Header: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/SimpleLog.java,v
1.8 2002/01/17 01:47:49 craigmcc Exp $
  + * $Revision: 1.8 $
  + * $Date: 2002/01/17 01:47:49 $
    *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -98,11 +98,12 @@
    * @author Rod Waldhoff
    * @author Robert Burrell Donkin
    *
  - * @version $Id: SimpleLog.java,v 1.7 2002/01/03 19:00:19 rdonkin Exp $
  + * @version $Id: SimpleLog.java,v 1.8 2002/01/17 01:47:49 craigmcc Exp $
    */
   public class SimpleLog extends AbstractLog {
   
  -    // --------------------------------------------------------- Class Attributes
  +
  +    // ------------------------------------------------------- Class Attributes
       
       /** All system properties used by <code>Simple</code> start with this */
       static protected final String _prefix =
  @@ -119,7 +120,7 @@
   
   
   
  -    // --------------------------------------------------------- Initializer
  +    // ------------------------------------------------------------ Initializer
   
       // initialize class attributes
       static {
  @@ -165,13 +166,13 @@
       }
   
   
  -    // --------------------------------------------------------- Attributes
  +    // ------------------------------------------------------------- Attributes
   
       /** The name of this simple log instance */
       protected String _name = null;
   
   
  -    // --------------------------------------------------------- Constructor
  +    // ------------------------------------------------------------ Constructor
       
       /** 
        * Construct a simple log with given name.
  @@ -213,8 +214,9 @@
       }
   
   
  -    // --------------------------------------------------------- Methods
  +    // -------------------------------------------------------- Logging Methods
       
  +
       /**
        * <p> Do the actual logging.
        * This method assembles the message 
  @@ -259,7 +261,8 @@
           System.out.println(buf.toString());
       }
   
  -    // --------------------------------------------------------- Log Implementation
  +
  +    // ----------------------------------------------------- Log Implementation
   
       /**
        * Prepare then call {@link #log}.
  
  
  

--
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