You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by ce...@apache.org on 2004/10/29 13:31:29 UTC

cvs commit: logging-log4j/src/java/org/apache/log4j Logger.java

ceki        2004/10/29 04:31:29

  Modified:    src/java/org/apache/log4j Logger.java
  Log:
  Committing intermediate work so that it does not get lost.
  
  Given that swapping Catgory and Logger derivation is likely to cause problems to
  to client who are oblivious to gump and other tracking tools, it is perhaps wiser to
  allow them one more chance to move to the Logger class.
  
  Thus, following this commit I will revert back to an earlier version
  (Category 1.88) where Category is still the super class of Logger.
  
  Revision  Changes    Path
  1.22      +51 -19    logging-log4j/src/java/org/apache/log4j/Logger.java
  
  Index: Logger.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/Logger.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- Logger.java	28 Oct 2004 12:51:30 -0000	1.21
  +++ Logger.java	29 Oct 2004 11:31:29 -0000	1.22
  @@ -33,6 +33,7 @@
   import org.apache.log4j.helpers.AppenderAttachableImpl;
   import org.apache.log4j.helpers.NullEnumeration;
   import org.apache.log4j.helpers.ReaderWriterLock;
  +import org.apache.log4j.helpers.mcompose.MessageComposer;
   import org.apache.log4j.spi.AppenderAttachable;
   import org.apache.log4j.spi.LoggerFactory;
   import org.apache.log4j.spi.LoggerRepository;
  @@ -118,21 +119,46 @@
     }
   
     /**
  -     Retrieve a logger by name.
  -  */
  +   * Retrieve a logger by name. If the named logger already exists, then the 
  +   * existing instance will be reutrned. Otherwise, a new instance is created. 
  +   * 
  +   * <p>By default, loggers do not have a set level but inherit it from their 
  +   * ancestors. This is one of the central features of log4j.
  +   * </p>
  +   * 
  +   * @param name The name of the logger to retrieve.
  +   */
     public static Logger getLogger(String name) {
       return LogManager.getLogger(name);
     }
   
  +  
     /**
  -     Same as calling <code>getLogger(clazz.getName())</code>.
  +   * Shorthand for <code>{@link #getLogger(Class) getLogger(clazz.getName())}</code>.
  +   *
  +   * @param clazz The name of <code>clazz</code> will be used as the name of
  +   *        the logger to retrieve.  See {@link #getLogger(String)} for
  +   *        more detailed information.
  +   * @since 1.0
      */
     public static Logger getLogger(Class clazz) {
       return LogManager.getLogger(clazz.getName());
     }
   
  +  
     /**
  -     Retrieve the root logger.
  +   * Return the root of logger for the current hierarchy.
  +   *
  +   * <p>
  +   * The root logger is always instantiated and available. It's name is
  +   * "root".
  +   * </p>
  +   *
  +   * <p>
  +   * Nevertheless, note that calling <code>Logger.getLogger("root")</code>
  +   * does not retrieve the root logger but a logger just under root named
  +   * "root".
  +   * </p>
      */
     public static Logger getRootLogger() {
       return LogManager.getRootLogger();
  @@ -327,6 +353,25 @@
       }
     }
   
  +  public void debug(Object message, Object param) {
  +    if (repository.isDisabled(Level.DEBUG_INT)) {
  +      return;
  +    }
  +
  +    if (Level.DEBUG.isGreaterOrEqual(this.getEffectiveLevel())) {
  +      if(param instanceof Throwable) {
  +        forcedLog(FQCN, Level.DEBUG, message, (Throwable) param);
  +      } else if (message instanceof String){
  +        String msgStr = (String) message;
  +        msgStr = MessageComposer.compose(msgStr, param);
  +        forcedLog(FQCN, Level.DEBUG, msgStr, null);
  +      } else {
  +        forcedLog(FQCN, Level.DEBUG, message, null);
  +      }
  +    }
  +  }
  +
  +  
     /**
      * Log a message object with the <code>DEBUG</code> level including the
      * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
  @@ -600,28 +645,15 @@
     }
   
     /**
  -   * Retrieve a logger with named as the <code>name</code> parameter. If the
  -   * named logger already exists, then the existing instance will be
  -   * reutrned. Otherwise, a new instance is created. By default, loggers
  -   * do not have a set level but inherit it from their ancestors. This is one
  -   * of the central features of log4j.
  -   *
  -   * @param name The name of the logger to retrieve.
  -   * @deprecated Please use the {@link LogManager#getLogger(String)} method
  -   * instead.
  +   * @deprecated Please use {@link LogManager#getLogger(String)} instead.
      */
     public static Logger getInstance(String name) {
       return LogManager.getLogger(name);
     }
   
  +  
     /**
  -   * Shorthand for <code>getInstance(clazz.getName())</code>.
  -   *
  -   * @param clazz The name of <code>clazz</code> will be used as the name of
  -   *        the logger to retrieve.  See {@link #getLogger(String)} for
  -   *        more detailed information.
      * @deprecated Please use {@link LogManager#getLogger(Class)} instead.
  -   * @since 1.0
      */
     public static Logger getInstance(Class clazz) {
       return LogManager.getLogger(clazz);
  
  
  

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