[89] | 1 | /*
|
---|
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more
|
---|
| 3 | * contributor license agreements. See the NOTICE file distributed with
|
---|
| 4 | * this work for additional information regarding copyright ownership.
|
---|
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0
|
---|
| 6 | * (the "License"); you may not use this file except in compliance with
|
---|
| 7 | * the License. You may obtain a copy of the License at
|
---|
| 8 | *
|
---|
| 9 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 10 | *
|
---|
| 11 | * Unless required by applicable law or agreed to in writing, software
|
---|
| 12 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
| 14 | * See the License for the specific language governing permissions and
|
---|
| 15 | * limitations under the License.
|
---|
| 16 | */
|
---|
| 17 |
|
---|
| 18 | #ifndef _LOG4CXX_SPI_LOG_REPOSITORY_H
|
---|
| 19 | #define _LOG4CXX_SPI_LOG_REPOSITORY_H
|
---|
| 20 |
|
---|
| 21 | #if defined(_MSC_VER)
|
---|
| 22 | #pragma warning ( push )
|
---|
| 23 | #pragma warning ( disable: 4231 4251 4275 4786 )
|
---|
| 24 | #endif
|
---|
| 25 |
|
---|
| 26 |
|
---|
| 27 | #include <log4cxx/appender.h>
|
---|
| 28 | #include <log4cxx/spi/loggerfactory.h>
|
---|
| 29 | #include <log4cxx/level.h>
|
---|
| 30 | #include <log4cxx/spi/hierarchyeventlistener.h>
|
---|
| 31 |
|
---|
| 32 | namespace log4cxx
|
---|
| 33 | {
|
---|
| 34 | namespace spi
|
---|
| 35 | {
|
---|
| 36 |
|
---|
| 37 | /**
|
---|
| 38 | A <code>LoggerRepository</code> is used to create and retrieve
|
---|
| 39 | <code>Loggers</code>. The relation between loggers in a repository
|
---|
| 40 | depends on the repository but typically loggers are arranged in a
|
---|
| 41 | named hierarchy.
|
---|
| 42 |
|
---|
| 43 | <p>In addition to the creational methods, a
|
---|
| 44 | <code>LoggerRepository</code> can be queried for existing loggers,
|
---|
| 45 | can act as a point of registry for events related to loggers.
|
---|
| 46 | */
|
---|
| 47 | class LOG4CXX_EXPORT LoggerRepository : public virtual helpers::Object
|
---|
| 48 | {
|
---|
| 49 | public:
|
---|
| 50 | DECLARE_ABSTRACT_LOG4CXX_OBJECT(LoggerRepository)
|
---|
| 51 | virtual ~LoggerRepository() {}
|
---|
| 52 |
|
---|
| 53 | /**
|
---|
| 54 | Add a {@link spi::HierarchyEventListener HierarchyEventListener}
|
---|
| 55 | event to the repository.
|
---|
| 56 | */
|
---|
| 57 | virtual void addHierarchyEventListener(const HierarchyEventListenerPtr&
|
---|
| 58 | listener) = 0;
|
---|
| 59 | /**
|
---|
| 60 | Is the repository disabled for a given level? The answer depends
|
---|
| 61 | on the repository threshold and the <code>level</code>
|
---|
| 62 | parameter. See also #setThreshold method. */
|
---|
| 63 | virtual bool isDisabled(int level) const = 0;
|
---|
| 64 |
|
---|
| 65 | /**
|
---|
| 66 | Set the repository-wide threshold. All logging requests below the
|
---|
| 67 | threshold are immediately dropped. By default, the threshold is
|
---|
| 68 | set to <code>Level::getAll()</code> which has the lowest possible rank. */
|
---|
| 69 | virtual void setThreshold(const LevelPtr& level) = 0;
|
---|
| 70 |
|
---|
| 71 | /**
|
---|
| 72 | Another form of {@link #setThreshold(const LevelPtr&)
|
---|
| 73 | setThreshold} accepting a string
|
---|
| 74 | parameter instead of a <code>Level</code>. */
|
---|
| 75 | virtual void setThreshold(const LogString& val) = 0;
|
---|
| 76 |
|
---|
| 77 | virtual void emitNoAppenderWarning(const LoggerPtr& logger) = 0;
|
---|
| 78 |
|
---|
| 79 | /**
|
---|
| 80 | Get the repository-wide threshold. See {@link
|
---|
| 81 | #setThreshold(const LevelPtr&) setThreshold}
|
---|
| 82 | for an explanation. */
|
---|
| 83 | virtual const LevelPtr& getThreshold() const = 0;
|
---|
| 84 |
|
---|
| 85 | virtual LoggerPtr getLogger(const LogString& name) = 0;
|
---|
| 86 |
|
---|
| 87 | virtual LoggerPtr getLogger(const LogString& name,
|
---|
| 88 | const spi::LoggerFactoryPtr& factory) = 0;
|
---|
| 89 |
|
---|
| 90 | virtual LoggerPtr getRootLogger() const = 0;
|
---|
| 91 |
|
---|
| 92 | virtual LoggerPtr exists(const LogString& name) = 0;
|
---|
| 93 |
|
---|
| 94 | virtual void shutdown() = 0;
|
---|
| 95 |
|
---|
| 96 | virtual LoggerList getCurrentLoggers() const = 0;
|
---|
| 97 |
|
---|
| 98 | virtual void fireAddAppenderEvent(const LoggerPtr& logger,
|
---|
| 99 | const AppenderPtr& appender) = 0;
|
---|
| 100 |
|
---|
| 101 | virtual void resetConfiguration() = 0;
|
---|
| 102 |
|
---|
| 103 | virtual bool isConfigured() = 0;
|
---|
| 104 | virtual void setConfigured(bool configured) = 0;
|
---|
| 105 |
|
---|
| 106 | }; // class LoggerRepository
|
---|
| 107 |
|
---|
| 108 | } // namespace spi
|
---|
| 109 | } // namespace log4cxx
|
---|
| 110 |
|
---|
| 111 | #if defined(_MSC_VER)
|
---|
| 112 | #pragma warning ( pop )
|
---|
| 113 | #endif
|
---|
| 114 |
|
---|
| 115 |
|
---|
| 116 | #endif //_LOG4CXX_SPI_LOG_REPOSITORY_H
|
---|