Apache Log4cxx  Version 1.2.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
24#include <vector>
25#include <map>
30
31namespace LOG4CXX_NS
32{
33
34class Hierarchy;
36
55class 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
83#if LOG4CXX_ABI_VERSION <= 15
84 void removeHierarchyEventListener(const spi::HierarchyEventListenerPtr& listener);
85#else
86 void removeHierarchyEventListener(const spi::HierarchyEventListenerPtr& listener) override;
87#endif
91 void ensureIsConfigured(std::function<void()> configurator) override;
92
101 void clear();
102
103 void emitNoAppenderWarning(const Logger* logger) override;
104
112 LoggerPtr exists(const LogString& name) override;
113
117 void setThreshold(const LogString& levelStr) override;
118
125 void setThreshold(const LevelPtr& newLevel) override;
126
127 void fireAddAppenderEvent(const Logger* logger, const Appender* appender) override;
128
129 void fireRemoveAppenderEvent(const Logger* logger, const Appender* appender) override;
130
135 LevelPtr getThreshold() const override;
136
148 LoggerPtr getLogger(const LogString& name) override;
149
164 const spi::LoggerFactoryPtr& factory) override;
165
173
177 LoggerPtr getRootLogger() const override;
178
184 bool isDisabled(int level) const override;
185
199 void resetConfiguration() override;
200
218 void shutdown() override;
219
220
221 virtual bool isConfigured() override;
222 virtual void setConfigured(bool configured) override;
223
227 void updateChildren(const Logger* parent);
228
230
231 void addAppender(AppenderPtr appender);
232
244#if LOG4CXX_ABI_VERSION <= 15
245 bool removeLogger(const LogString& name, bool ifNotUsed = true);
246#else
247 bool removeLogger(const LogString& name, bool ifNotUsed = true) override;
248#endif
249
250 private:
251
255 void setThresholdInternal(const LevelPtr& l);
256
260 void shutdownInternal();
261
285 void updateParents(const LoggerPtr& logger, const LoggerPtr& root);
286
301 void updateChildren(ProvisionNode& pn, const LoggerPtr& logger);
302
303 Hierarchy(const Hierarchy&);
304 Hierarchy& operator=(const Hierarchy&);
305
306};
307
308} //namespace log4cxx
309
310#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.
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
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
LOG4CXX_PTR_DEF(Appender)
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 BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:146