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/06/07 19:25:39 UTC

cvs commit: logging-log4j/src/java/org/apache/ugli NullLoggerRepository.java LoggerRepository.java Logger.java NullLogger.java

ceki        2004/06/07 10:25:39

  Added:       src/java/org/apache/ugli NullLoggerRepository.java
                        LoggerRepository.java Logger.java NullLogger.java
  Log:
  Started work on UGLI.
  
  Revision  Changes    Path
  1.1                  logging-log4j/src/java/org/apache/ugli/NullLoggerRepository.java
  
  Index: NullLoggerRepository.java
  ===================================================================
  /*
   * Copyright 1999,2004 The Apache Software Foundation.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.ugli;
  
  
  /**
   * 
   * The NullLoggerRepository returns instances of {@link NullLogger}.
   * @author Ceki Gücü
   */
  public class NullLoggerRepository implements LoggerRepository {
  
    /* Always returns a {@link NullLogger}.
     * @see org.apache.ugli.LoggerRepository#getLogger(java.lang.String)
     */
    public Logger getLogger(String name) {
      return NullLogger.NULL_LOGGER;
    }
  
    /* Always returns a {@link NullLogger}.
     * @see org.apache.ugli.LoggerRepository#getLogger(java.lang.String, java.lang.String)
     */
    public Logger getLogger(String domainName, String subDomainName) {
      return NullLogger.NULL_LOGGER;
    }
  
    /* Always returns a {@link NullLogger}.
     * @see org.apache.ugli.LoggerRepository#getLogger(java.lang.Class)
     */
    public Logger getLogger(Class clazz) {
      return NullLogger.NULL_LOGGER;
    }
  
    /* Always returns a {@link NullLogger}.
     * @see org.apache.ugli.LoggerRepository#getLogger(java.lang.Class, java.lang.String)
     */
    public Logger getLogger(Class clazz, String subDomainName) {
      return NullLogger.NULL_LOGGER;
    }
  
    /* Always returns a {@link NullLogger}.
     * @see org.apache.ugli.LoggerRepository#close()
     */
    public void close() {
      // NOP
    }
  
  }
  
  
  
  1.1                  logging-log4j/src/java/org/apache/ugli/LoggerRepository.java
  
  Index: LoggerRepository.java
  ===================================================================
  /*
   * Copyright 1999,2004 The Apache Software Foundation.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package org.apache.ugli;
  
  
  /**
   * A LoggerRepository is an application specific object that returns 
   * {@link Logger} instances.
   * 
   * @author Ceki Gülcü
   */
  public interface LoggerRepository {
  
    
    public Logger getLogger(String name);
    public Logger getLogger(String domainName, String subDomainName);
    public Logger getLogger(Class clazz);
    public Logger getLogger(Class clazz, String subDomainName);
    
    
    public void close();
  }
  
  
  
  1.1                  logging-log4j/src/java/org/apache/ugli/Logger.java
  
  Index: Logger.java
  ===================================================================
  /*
   * Copyright 1999,2004 The Apache Software Foundation.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package org.apache.ugli;
  
  
  /**
   * 
   * The main user inteface to logging. It is expected that logging takes places
   * through concerete implemetations of the Logger interface.
   *  
   * 
   * @author Ceki Gülcü
   */
  public interface Logger {
  
  
    /**
     * Is the logger instance enabled for the DEBUG level?
     * @return 
     */
    public boolean isDebugEnabled();
  //
    
    /**
     * Log a message object with the DEBUG level. 
     * @param msg - the message object to be logged
     */
    public void debug(Object msg);
    
    
    /**
     * Log a parameterized message object at the DEBUG level. 
     * 
     * <p>This form is useful in avoiding the superflous object creation
     * problem when invoking this method while it is disabled.
     * </p>
     * @param parameterizedMsg - the parameterized message object
     * @param param1 - the parameter 
     */
    public void debug(Object parameterizedMsg, Object param1);
    
    /**
     * Log a parameterized message object at the DEBUG level. 
     * 
     * <p>This form is useful in avoiding the superflous object creation
     * problem when invoking this method while it is disabled.
     * </p>
     * @param parameterizedMsg - the parameterized message object
     * @param param1 - the first parameter 
     * @param param2 - the second parameter 
     */
    public void debug(Object parameterizedMsg, Object param1, Object param2);
    public void debug(Object msg, Throwable t);
  
  
    public boolean isInfoEnabled();
    public void info(Object msg);
    public void info(Object parameterizedMsg, Object param1);
    public void info(Object parameterizedMsg, Object param1, Object param2);
    public void info(Object msg, Throwable t);
  
  
    public boolean isWarnEnabled();
    public void warn(Object msg);
    public void warn(Object parameterizedMsg, Object param1);
    public void warn(Object parameterizedMsg, Object param1, Object param2);
    public void warn(Object msg, Throwable t);
  
  
    public boolean isErrorEnabled();
    public void error(Object msg);
    public void error(Object parameterizedMsg, Object param1);
    public void error(Object parameterizedMsg, Object param1, Object param2);
    public void error(Object msg, Throwable t);
  
  }
  
  
  
  1.1                  logging-log4j/src/java/org/apache/ugli/NullLogger.java
  
  Index: NullLogger.java
  ===================================================================
  /*
   * Copyright 1999,2004 The Apache Software Foundation.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.ugli;
  
  
  /**
   * A no operation (NOP) implementation of {@link Logger}.
   * 
   * @author Ceki G&uuml;lc&uuml;
   */
  public class NullLogger implements Logger {
  
    /**
     * The unique instance of NullLogger.
     */
    public final static NullLogger NULL_LOGGER = new NullLogger();
    
    /**
     * There is no point in people creating multiple instances of NullLogger. 
     * Hence, the private access modifier. 
     */
    private NullLogger() {
    }
    
    /* Always returns false.
     * 
     * @see org.apache.ugli.Logger#isDebugEnabled()
     */
    public boolean isDebugEnabled() {
      return false;
    }
  
    /* A NOP implementation.
     * @see org.apache.ugli.Logger#debug(java.lang.Object)
     */
    public void debug(Object msg) {
      // NOP
    }
  
    /* A NOP implementation.
     * @see org.apache.ugli.Logger#debug(java.lang.Object, java.lang.Object)
     */
    public void debug(Object parameterizedMsg, Object param1) {
      // NOP
    }
  
    /* A NOP implementation.
     * @see org.apache.ugli.Logger#debug(java.lang.Object, java.lang.Object, java.lang.Object)
     */
    public void debug(Object parameterizedMsg, Object param1, Object param2) {
      // NOP
    }
  
    /* A NOP implementation.
     * @see org.apache.ugli.Logger#debug(java.lang.Object, java.lang.Throwable)
     */
    public void debug(Object msg, Throwable t) {
      // NOP
    }
  
    /* Always returns false.
     * @see org.apache.ugli.Logger#isInfoEnabled()
     */
    public boolean isInfoEnabled() {
      // NOP
      return false;
    }
  
    /* A NOP implementation.
     * @see org.apache.ugli.Logger#info(java.lang.Object)
     */
    public void info(Object msg) {
      // NOP
    }
  
    /* A NOP implementation.
     * @see org.apache.ugli.Logger#info(java.lang.Object, java.lang.Object)
     */
    public void info(Object parameterizedMsg, Object param1) {
      // NOP
    }
  
    /* A NOP implementation.
     * @see org.apache.ugli.Logger#info(java.lang.Object, java.lang.Object, java.lang.Object)
     */
    public void info(Object parameterizedMsg, Object param1, Object param2) {
      // NOP
    }
  
    /* A NOP implementation.
     * @see org.apache.ugli.Logger#info(java.lang.Object, java.lang.Throwable)
     */
    public void info(Object msg, Throwable t) {
      // NOP
    }
  
    /* Always returns false.
     * @see org.apache.ugli.Logger#isWarnEnabled()
     */
    public boolean isWarnEnabled() {
      return false;
    }
  
    /* A NOP implementation.
     * @see org.apache.ugli.Logger#warn(java.lang.Object)
     */
    public void warn(Object msg) {
      // NOP
    }
  
    /* A NOP implementation.
     * @see org.apache.ugli.Logger#warn(java.lang.Object, java.lang.Object)
     */
    public void warn(Object parameterizedMsg, Object param1) {
      // NOP
    }
  
    /* A NOP implementation.
     * @see org.apache.ugli.Logger#warn(java.lang.Object, java.lang.Object, java.lang.Object)
     */
    public void warn(Object parameterizedMsg, Object param1, Object param2) {
      // NOP
    }
  
    /* A NOP implementation.
     * @see org.apache.ugli.Logger#warn(java.lang.Object, java.lang.Throwable)
     */
    public void warn(Object msg, Throwable t) {
      // NOP
    }
  
    /* Always returns false.
     * @see org.apache.ugli.Logger#isErrorEnabled()
     */
    public boolean isErrorEnabled() {
      return false;
    }
  
    /* A NOP implementation.
     * @see org.apache.ugli.Logger#error(java.lang.Object)
     */
    public void error(Object msg) {
      // NOP
    }
  
    /* A NOP implementation.
     * @see org.apache.ugli.Logger#error(java.lang.Object, java.lang.Object)
     */
    public void error(Object parameterizedMsg, Object param1) {
      // NOP
    }
  
    /* A NOP implementation.
     * @see org.apache.ugli.Logger#error(java.lang.Object, java.lang.Object, java.lang.Object)
     */
    public void error(Object parameterizedMsg, Object param1, Object param2) {
      // NOP
    }
  
    /* A NOP implementation.
     * @see org.apache.ugli.Logger#error(java.lang.Object, java.lang.Throwable)
     */
    public void error(Object msg, Throwable t) {
      // NOP
    }
  
  }
  
  
  

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