Apache Log4cxx  Version 1.3.0
Loading...
Searching...
No Matches
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
26
27namespace LOG4CXX_NS
28{
29
30class Hierarchy;
32
52{
53 private:
54 LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(HierarchyPrivate, m_priv)
55
56 public:
59#if 15 < LOG4CXX_ABI_VERSION
62#else
64#endif
66
67 private:
71 Hierarchy();
72
73 public:
74 static HierarchyPtr create();
75
77
78 void addHierarchyEventListener(const spi::HierarchyEventListenerPtr& listener) override;
79
84#if LOG4CXX_ABI_VERSION <= 15
85 void removeHierarchyEventListener(const spi::HierarchyEventListenerPtr& listener);
86#else
87 void removeHierarchyEventListener(const spi::HierarchyEventListenerPtr& listener) override;
88#endif
92 void ensureIsConfigured(std::function<void()> configurator) override;
93
102 void clear();
103
104 void emitNoAppenderWarning(const Logger* logger) override;
105
113 LoggerPtr exists(const LogString& name) override;
114
118 void setThreshold(const LogString& levelStr) override;
119
126 void setThreshold(const LevelPtr& newLevel) override;
127
128 void fireAddAppenderEvent(const Logger* logger, const Appender* appender) override;
129
130 void fireRemoveAppenderEvent(const Logger* logger, const Appender* appender) override;
131
136 LevelPtr getThreshold() const override;
137
149 LoggerPtr getLogger(const LogString& name) override;
150
165 const spi::LoggerFactoryPtr& factory) override;
166
174
178 LoggerPtr getRootLogger() const override;
179
185 bool isDisabled(int level) const override;
186
200 void resetConfiguration() override;
201
219 void shutdown() override;
220
221
222 virtual bool isConfigured() override;
223 virtual void setConfigured(bool configured) override;
224
228 void updateChildren(const Logger* parent);
229
231
232 void addAppender(AppenderPtr appender);
233
245#if LOG4CXX_ABI_VERSION <= 15
246 bool removeLogger(const LogString& name, bool ifNotUsed = true);
247#else
248 bool removeLogger(const LogString& name, bool ifNotUsed = true) override;
249#endif
250
251 private:
252
256 void setThresholdInternal(const LevelPtr& l);
257
261 void shutdownInternal();
262
286 void updateParents(const LoggerPtr& logger, const LoggerPtr& root);
287
302 void updateChildren(ProvisionNode& pn, const LoggerPtr& logger);
303
304 Hierarchy(const Hierarchy&);
305 Hierarchy& operator=(const Hierarchy&);
306
307};
308
309} //namespace log4cxx
310
311#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:52
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.
void removeHierarchyEventListener(const spi::HierarchyEventListenerPtr &listener)
Remove a previously added HierarchyEventListener.
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)
void setThreshold(const LevelPtr &newLevel) override
Enable logging for logging requests with level newLevel or higher.
bool removeLogger(const LogString &name, bool ifNotUsed=true)
Remove the name Logger from the hierarchy.
virtual void setConfigured(bool configured) override
void fireAddAppenderEvent(const Logger *logger, const Appender *appender) override
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: log4cxx/logger.h:51
A LoggerRepository is used to create and retrieve Loggers.
Definition: loggerrepository.h:43
#define LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(T, V)
Definition: log4cxx.h:85
#define LOG4CXX_EXPORT
Definition: log4cxx.h:101
#define LOG4CXX_PTR_DEF(T)
Definition: log4cxx.h:64
#define LOG4CXX_NS
Definition: log4cxx.h:104
std::shared_ptr< LoggerFactory > LoggerFactoryPtr
Definition: logmanager.h:34
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:28
std::shared_ptr< Appender > AppenderPtr
Definition: basicconfigurator.h:29
std::shared_ptr< Logger > LoggerPtr
Definition: defaultloggerfactory.h:27
std::vector< LoggerPtr > LoggerList
Definition: logmanager.h:29
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:158
#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)
Definition: object.h:39
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:152
#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)
Definition: object.h:164
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:146