Apache log4cxx Version 0.13.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#if defined(_MSC_VER)
22 #pragma warning (push)
23 #pragma warning ( disable: 4231 4251 4275 4786 )
24#endif
25
28#include <vector>
29#include <map>
34
35namespace log4cxx
36{
37
38class Hierarchy;
40
59class LOG4CXX_EXPORT Hierarchy :
60 public virtual spi::LoggerRepository,
61 public virtual helpers::Object,
62 public std::enable_shared_from_this<Hierarchy>
63{
64 private:
66 mutable std::mutex mutex;
67 bool configured;
68
69 spi::LoggerFactoryPtr defaultFactory;
70 spi::HierarchyEventListenerList listeners;
71
72 typedef std::map<LogString, LoggerPtr> LoggerMap;
73 std::unique_ptr<LoggerMap> loggers;
74
75 typedef std::map<LogString, ProvisionNode> ProvisionNodeMap;
76 std::unique_ptr<ProvisionNodeMap> provisionNodes;
77
78 LoggerPtr root;
79
80 int thresholdInt;
81 LevelPtr threshold;
82
83 bool emittedNoAppenderWarning;
84 bool emittedNoResourceBundleWarning;
85
86 public:
91
92 private:
96 Hierarchy();
97
98 public:
99 static HierarchyPtr create();
100
102
103 void addHierarchyEventListener(const spi::HierarchyEventListenerPtr& listener);
104
113 void clear();
114
115 void emitNoAppenderWarning(const Logger* logger);
116
125
129 void setThreshold(const LogString& levelStr);
130
137 void setThreshold(const LevelPtr& l);
138
139 void fireAddAppenderEvent(const Logger* logger, const Appender* appender);
140
141 void fireRemoveAppenderEvent(const Logger* logger,
142 const Appender* appender);
143
148 const LevelPtr& getThreshold() const;
149
162
177 const spi::LoggerFactoryPtr& factory);
178
186
191
197 bool isDisabled(int level) const;
198
213
231 void shutdown();
232
233
234 virtual bool isConfigured();
235 virtual void setConfigured(bool configured);
236
237
238 private:
239
243 void setThresholdInternal(const LevelPtr& l);
244
248 void shutdownInternal();
249
270 void updateParents(LoggerPtr logger);
271
286 Hierarchy(const Hierarchy&);
287 Hierarchy& operator=(const Hierarchy&);
288
289 void updateChildren(ProvisionNode& pn, LoggerPtr logger);
290
291};
292
293} //namespace log4cxx
294
295
296#if defined(_MSC_VER)
297 #pragma warning (pop)
298#endif
299
300#endif //_LOG4CXX_HIERARCHY_H
Implement this interface for your own strategies for outputting log statements.
Definition: appender.h:57
This class is specialized in retrieving loggers by name and also maintaining the logger hierarchy.
Definition: hierarchy.h:63
LoggerPtr exists(const LogString &name)
Check if the named logger exists in the hierarchy.
bool isDisabled(int level) const
This method will return true if this repository is disabled for level object passed as parameter and ...
void resetConfiguration()
Reset all values contained in this hierarchy instance to their default.
virtual void setConfigured(bool configured)
void addHierarchyEventListener(const spi::HierarchyEventListenerPtr &listener)
void fireAddAppenderEvent(const Logger *logger, const Appender *appender)
void emitNoAppenderWarning(const Logger *logger)
LoggerPtr getLogger(const LogString &name, const spi::LoggerFactoryPtr &factory)
Return a new logger instance named as the first parameter using factory.
LoggerList getCurrentLoggers() const
Returns all the currently defined loggers in this hierarchy as a LoggerList.
LoggerPtr getRootLogger() const
Get the root of this hierarchy.
static HierarchyPtr create()
void setThreshold(const LevelPtr &l)
Enable logging for logging requests with level l or higher.
void shutdown()
Used by subclasses to add a renderer to the hierarchy passed as parameter.
void setThreshold(const LogString &levelStr)
The string form of setThreshold.
virtual bool isConfigured()
LoggerPtr getLogger(const LogString &name)
Return a new logger instance named as the first parameter using the default factory.
void fireRemoveAppenderEvent(const Logger *logger, const Appender *appender)
void clear()
This call will clear all logger definitions from the internal hashtable.
const LevelPtr & getThreshold() const
Returns a Level representation of the enable state.
This is the central class in the log4cxx package.
Definition: logger.h:66
base class for java-like objects.
Definition: object.h:102
Definition: pool.h:33
A LoggerRepository is used to create and retrieve Loggers.
Definition: loggerrepository.h:48
std::shared_ptr< LoggerFactory > LoggerFactoryPtr
Definition: logmanager.h:39
Definition: messagehandler.h:23
std::vector< LoggerPtr > ProvisionNode
Definition: provisionnode.h:31
std::basic_string< logchar > LogString
Definition: logstring.h:66
std::shared_ptr< Level > LevelPtr
Definition: optionconverter.h:28
LOG4CXX_PTR_DEF(Appender)
std::shared_ptr< Logger > LoggerPtr
Definition: defaultloggerfactory.h:27
std::vector< LoggerPtr > LoggerList
Definition: logmanager.h:34
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:153
#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)
Definition: object.h:26
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:147
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:141