Apache Log4cxx  Version 1.1.0
hierarchy.h
Go to the documentation of this file.
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_HIERARCHY_H
19 #define _LOG4CXX_HIERARCHY_H
20 
21 
24 #include <vector>
25 #include <map>
26 #include <log4cxx/provisionnode.h>
27 #include <log4cxx/helpers/object.h>
29 #include <log4cxx/helpers/pool.h>
30 
31 namespace log4cxx
32 {
33 
34 class Hierarchy;
36 
55 class LOG4CXX_EXPORT Hierarchy : public spi::LoggerRepository
56 {
57  private:
58  LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(HierarchyPrivate, m_priv)
59 
60  public:
65 
66  private:
70  Hierarchy();
71 
72  public:
73  static HierarchyPtr create();
74 
76 
77  void addHierarchyEventListener(const spi::HierarchyEventListenerPtr& listener) override;
78 
82  void ensureIsConfigured(std::function<void()> configurator) override;
83 
92  void clear();
93 
94  void emitNoAppenderWarning(const Logger* logger) override;
95 
103  LoggerPtr exists(const LogString& name) override;
104 
108  void setThreshold(const LogString& levelStr) override;
109 
116  void setThreshold(const LevelPtr& l) override;
117 
118  void fireAddAppenderEvent(const Logger* logger, const Appender* appender) override;
119 
120  void fireRemoveAppenderEvent(const Logger* logger, const Appender* appender) override;
121 
126  LevelPtr getThreshold() const override;
127 
139  LoggerPtr getLogger(const LogString& name) override;
140 
155  const spi::LoggerFactoryPtr& factory) override;
156 
163  LoggerList getCurrentLoggers() const override;
164 
168  LoggerPtr getRootLogger() const override;
169 
175  bool isDisabled(int level) const override;
176 
190  void resetConfiguration() override;
191 
209  void shutdown() override;
210 
211 
212  virtual bool isConfigured() override;
213  virtual void setConfigured(bool configured) override;
214 
218  void updateChildren(const Logger* parent);
219 
221 
222  void addAppender(AppenderPtr appender);
223 
224  private:
225 
229  void setThresholdInternal(const LevelPtr& l);
230 
234  void shutdownInternal();
235 
259  void updateParents(const LoggerPtr& logger, const LoggerPtr& root);
260 
275  void updateChildren(ProvisionNode& pn, const LoggerPtr& logger);
276 
277  Hierarchy(const Hierarchy&);
278  Hierarchy& operator=(const Hierarchy&);
279 
280 };
281 
282 } //namespace log4cxx
283 
284 #endif //_LOG4CXX_HIERARCHY_H
Implement this interface for your own strategies for outputting log statements.
Definition: appender.h:51
This class is specialized in retrieving loggers by name and also maintaining the logger hierarchy.
Definition: hierarchy.h:56
void ensureIsConfigured(std::function< void()> configurator) override
Call configurator if not yet configured.
LoggerList getCurrentLoggers() const override
Returns all the currently defined loggers in this hierarchy as a LoggerList.
void emitNoAppenderWarning(const Logger *logger) override
LoggerPtr getRootLogger() const override
Get the root of this hierarchy.
void resetConfiguration() override
Reset all values contained in this hierarchy instance to their default.
LevelPtr getThreshold() const override
Returns a Level representation of the enable state.
LoggerPtr exists(const LogString &name) override
Check if the named logger exists in the hierarchy.
LoggerPtr getLogger(const LogString &name) override
Retrieve the name Logger instance using the default factory to create it if required.
void addAppender(AppenderPtr appender)
virtual void setConfigured(bool configured) override
void fireAddAppenderEvent(const Logger *logger, const Appender *appender) override
void setThreshold(const LevelPtr &l) override
Enable logging for logging requests with level l or higher.
static HierarchyPtr create()
bool isDisabled(int level) const override
This method will return true if this repository is disabled for level object passed as parameter and ...
void updateChildren(const Logger *parent)
Refresh the threshold in children of parent.
virtual bool isConfigured() override
void addHierarchyEventListener(const spi::HierarchyEventListenerPtr &listener) override
void clear()
This call will clear all logger definitions from the internal hashtable.
void setThreshold(const LogString &levelStr) override
The string form of setThreshold.
LoggerPtr getLogger(const LogString &name, const spi::LoggerFactoryPtr &factory) override
Retrieve the name Logger instance using factory to create it if required.
void fireRemoveAppenderEvent(const Logger *logger, const Appender *appender) override
void shutdown() override
Used by subclasses to add a renderer to the hierarchy passed as parameter.
This is the central class in the log4cxx package.
Definition: logger.h:51
A LoggerRepository is used to create and retrieve Loggers.
Definition: loggerrepository.h:43
std::shared_ptr< LoggerFactory > LoggerFactoryPtr
Definition: logmanager.h:33
Definition: appender.h:27
std::vector< LoggerPtr > ProvisionNode
Definition: provisionnode.h:31
std::basic_string< logchar > LogString
Definition: logstring.h:60
std::shared_ptr< Level > LevelPtr
Definition: optionconverter.h:27
LOG4CXX_PTR_DEF(Appender)
std::shared_ptr< Appender > AppenderPtr
Definition: basicconfigurator.h:28
std::shared_ptr< Logger > LoggerPtr
Definition: defaultloggerfactory.h:26
std::vector< LoggerPtr > LoggerList
Definition: logmanager.h:29
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:157
#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)
Definition: object.h:38
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:151
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:145