geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject cvs commit: incubator-geronimo/modules/common/src/java/org/apache/geronimo/common/log/log4j CachingLog4jLog.java Log4jLog.java
Date Wed, 27 Aug 2003 11:15:28 GMT
jdillon     2003/08/27 04:15:28

  Modified:    modules/common/src/java/org/apache/geronimo/common/log/log4j
                        CachingLog4jLog.java Log4jLog.java
  Log:
   o Not forcing warn, error and fatal to always be true
   o Using Level instead of Priority
  
  Revision  Changes    Path
  1.2       +13 -50    incubator-geronimo/modules/common/src/java/org/apache/geronimo/common/log/log4j/CachingLog4jLog.java
  
  Index: CachingLog4jLog.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/common/src/java/org/apache/geronimo/common/log/log4j/CachingLog4jLog.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CachingLog4jLog.java	27 Aug 2003 10:08:45 -0000	1.1
  +++ CachingLog4jLog.java	27 Aug 2003 11:15:27 -0000	1.2
  @@ -56,25 +56,26 @@
   package org.apache.geronimo.common.log.log4j;
   
   import java.lang.ref.WeakReference;
  +
   import java.util.HashSet;
   import java.util.Iterator;
   import java.util.Set;
   import java.util.Timer;
   import java.util.TimerTask;
   
  -import org.apache.log4j.Logger;
  -import org.apache.log4j.Priority;
  -
   import org.apache.commons.logging.Log;
   
  +import org.apache.log4j.Logger;
  +import org.apache.log4j.Level;
  +
   /**
    * This log wrapper caches the trace, debug and info enabled flags.  The flags are updated
  - * by a single timer task for all logs.  The error, warn and fatal levels are always enabled.
  + * by a single timer task for all logs.
    *
    * @version $Revision$ $Date$
    */
   public final class CachingLog4jLog
  -    implements Log
  +    extends Log4jLog
   {
       // @todo this need to be moved to a log manager MBean, but this works as a proof of
concept
       private static final Set logs = new HashSet();
  @@ -111,20 +112,18 @@
           }
       }
   
  -    private static final String FQCN = CachingLog4jLog.class.getName();
  -    private final Logger logger;
       private boolean traceEnabled;
       private boolean debugEnabled;
       private boolean infoEnabled;
   
       public CachingLog4jLog(String name) {
  -        logger = Logger.getLogger(name);
  +        super(name);
           updateLevelInfo();
           addLog(this);
       }
   
       public CachingLog4jLog(Logger logger) {
  -        this.logger = logger;
  +        super(logger);
           updateLevelInfo();
           addLog(this);
       }
  @@ -151,13 +150,13 @@
   
       public void debug(Object message) {
           if (debugEnabled) {
  -            logger.log(FQCN, Priority.DEBUG, message, null);
  +            logger.log(FQCN, Level.DEBUG, message, null);
           }
       }
   
       public void debug(Object message, Throwable throwable) {
           if (debugEnabled) {
  -            logger.log(FQCN, Priority.DEBUG, message, throwable);
  +            logger.log(FQCN, Level.DEBUG, message, throwable);
           }
       }
   
  @@ -167,50 +166,14 @@
   
       public void info(Object message) {
           if (infoEnabled) {
  -            logger.log(FQCN, Priority.INFO, message, null);
  +            logger.log(FQCN, Level.INFO, message, null);
           }
       }
   
       public void info(Object message, Throwable throwable) {
           if (infoEnabled) {
  -            logger.log(FQCN, Priority.INFO, message, throwable);
  +            logger.log(FQCN, Level.INFO, message, throwable);
           }
  -    }
  -
  -    public boolean isWarnEnabled() {
  -        return true;
  -    }
  -
  -    public void warn(Object message) {
  -        logger.log(FQCN, Priority.WARN, message, null);
  -    }
  -
  -    public void warn(Object message, Throwable throwable) {
  -        logger.log(FQCN, Priority.WARN, message, throwable);
  -    }
  -
  -    public boolean isErrorEnabled() {
  -        return true;
  -    }
  -
  -    public void error(Object message) {
  -        logger.log(FQCN, Priority.ERROR, message, null);
  -    }
  -
  -    public void error(Object message, Throwable throwable) {
  -        logger.log(FQCN, Priority.ERROR, message, throwable);
  -    }
  -
  -    public boolean isFatalEnabled() {
  -        return true;
  -    }
  -
  -    public void fatal(Object message) {
  -        logger.log(FQCN, Priority.FATAL, message, null);
  -    }
  -
  -    public void fatal(Object message, Throwable throwable) {
  -        logger.log(FQCN, Priority.FATAL, message, throwable);
       }
   
       private void updateLevelInfo() {
  
  
  
  1.2       +22 -21    incubator-geronimo/modules/common/src/java/org/apache/geronimo/common/log/log4j/Log4jLog.java
  
  Index: Log4jLog.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/common/src/java/org/apache/geronimo/common/log/log4j/Log4jLog.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Log4jLog.java	27 Aug 2003 10:08:45 -0000	1.1
  +++ Log4jLog.java	27 Aug 2003 11:15:27 -0000	1.2
  @@ -56,8 +56,9 @@
   package org.apache.geronimo.common.log.log4j;
   
   import org.apache.commons.logging.Log;
  +
   import org.apache.log4j.Logger;
  -import org.apache.log4j.Priority;
  +import org.apache.log4j.Level;
   
   /**
    * A Commons <code>Log</code> implementation for Log4j which supports
  @@ -68,20 +69,20 @@
   public class Log4jLog
       implements Log
   {
  -    private String FQCN = getClass().getName();
  -    private Logger logger;
  +    protected final String FQCN = getClass().getName();
  +    protected Logger logger;
   
       public Log4jLog() {
       }
   
  -    public Log4jLog(String name) {
  -        logger = Logger.getLogger(name);
  -    }
  -
       public Log4jLog(Logger logger) {
           this.logger = logger;
       }
   
  +    public Log4jLog(String name) {
  +        logger = Logger.getLogger(name);
  +    }
  +    
       public boolean isTraceEnabled() {
           return logger.isEnabledFor(XLevel.TRACE);
       }
  @@ -99,11 +100,11 @@
       }
   
       public void debug(Object message) {
  -        logger.log(FQCN, Priority.DEBUG, message, null);
  +        logger.log(FQCN, Level.DEBUG, message, null);
       }
   
       public void debug(Object message, Throwable throwable) {
  -        logger.log(FQCN, Priority.DEBUG, message, throwable);
  +        logger.log(FQCN, Level.DEBUG, message, throwable);
       }
   
       public boolean isInfoEnabled() {
  @@ -111,46 +112,46 @@
       }
   
       public void info(Object message) {
  -        logger.log(FQCN, Priority.INFO, message, null);
  +        logger.log(FQCN, Level.INFO, message, null);
       }
   
       public void info(Object message, Throwable throwable) {
  -        logger.log(FQCN, Priority.INFO, message, throwable);
  +        logger.log(FQCN, Level.INFO, message, throwable);
       }
   
       public boolean isWarnEnabled() {
  -        return true;
  +        return logger.isEnabledFor(Level.WARN);
       }
   
       public void warn(Object message) {
  -        logger.log(FQCN, Priority.WARN, message, null);
  +        logger.log(FQCN, Level.WARN, message, null);
       }
   
       public void warn(Object message, Throwable throwable) {
  -        logger.log(FQCN, Priority.WARN, message, throwable);
  +        logger.log(FQCN, Level.WARN, message, throwable);
       }
   
       public boolean isErrorEnabled() {
  -        return true;
  +        return logger.isEnabledFor(Level.ERROR);
       }
   
       public void error(Object message) {
  -        logger.log(FQCN, Priority.ERROR, message, null);
  +        logger.log(FQCN, Level.ERROR, message, null);
       }
   
       public void error(Object message, Throwable throwable) {
  -        logger.log(FQCN, Priority.ERROR, message, throwable);
  +        logger.log(FQCN, Level.ERROR, message, throwable);
       }
   
       public boolean isFatalEnabled() {
  -        return true;
  +        return logger.isEnabledFor(Level.FATAL);
       }
   
       public void fatal(Object message) {
  -        logger.log(FQCN, Priority.FATAL, message, null);
  +        logger.log(FQCN, Level.FATAL, message, null);
       }
   
       public void fatal(Object message, Throwable throwable) {
  -        logger.log(FQCN, Priority.FATAL, message, throwable);
  +        logger.log(FQCN, Level.FATAL, message, throwable);
       }
   }
  
  
  

Mime
View raw message