001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.log4j.spi;
018
019import org.apache.log4j.Level;
020import org.apache.log4j.Category;
021import org.apache.log4j.Logger;
022import org.apache.log4j.Appender;
023
024import java.util.Enumeration;
025import java.util.Vector;
026
027/**
028 *  No-operation implementation of LoggerRepository which is used when
029 *  LogManager.repositorySelector is erroneously nulled during class reloading.
030 *  @since 1.2.15
031 */
032public final class NOPLoggerRepository implements LoggerRepository {
033    /**
034     * {@inheritDoc}
035    */
036    public void addHierarchyEventListener(final HierarchyEventListener listener) {
037    }
038
039    /**
040     * {@inheritDoc}
041     */
042    public boolean isDisabled(final int level) {
043        return true;
044    }
045
046    /**
047     * {@inheritDoc}
048     */
049    public void setThreshold(final Level level) {
050    }
051
052    /**
053     * {@inheritDoc}
054     */
055    public void setThreshold(final String val) {
056    }
057
058    /**
059     * {@inheritDoc}
060     */
061    public void emitNoAppenderWarning(final Category cat) {
062    }
063
064    /**
065     * {@inheritDoc}
066     */
067    public Level getThreshold() {
068        return Level.OFF;
069    }
070
071    /**
072     * {@inheritDoc}
073     */
074    public Logger getLogger(final String name) {
075        return new NOPLogger(this, name);
076    }
077
078    /**
079     * {@inheritDoc}
080     */
081    public Logger getLogger(final String name, final LoggerFactory factory) {
082        return new NOPLogger(this, name);
083    }
084
085    /**
086     * {@inheritDoc}
087     */
088    public Logger getRootLogger() {
089        return new NOPLogger(this, "root");
090    }
091
092    /**
093     * {@inheritDoc}
094     */
095    public Logger exists(final String name) {
096        return null;
097    }
098
099    /**
100     * {@inheritDoc}
101     */
102    public void shutdown() {
103    }
104
105    /**
106     * {@inheritDoc}
107     */
108    public Enumeration getCurrentLoggers() {
109        return new Vector().elements();
110    }
111
112    /**
113     * {@inheritDoc}
114     */
115    public Enumeration getCurrentCategories() {
116        return getCurrentLoggers();
117    }
118
119
120    /**
121     * {@inheritDoc}
122     */
123    public  void fireAddAppenderEvent(Category logger, Appender appender) {
124    }
125
126    /**
127     * {@inheritDoc}
128     */
129    public void resetConfiguration() {
130    }
131}