Apache Log4cxx  Version 2.0.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
51class LOG4CXX_EXPORT Hierarchy : public spi::LoggerRepository
52{
53 private:
54 LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(HierarchyPrivate, m_priv)
55
56 public:
59 LOG4CXX_CAST_ENTRY(Hierarchy)
62
63 private:
67 Hierarchy();
68
69 public:
73 static HierarchyPtr create();
74
76
79 void addHierarchyEventListener(const spi::HierarchyEventListenerPtr& listener) override;
80
83 void removeHierarchyEventListener(const spi::HierarchyEventListenerPtr& listener) override;
84
87 void ensureIsConfigured(std::function<void()> configurator) override;
88
97 void clear();
98
99 void emitNoAppenderWarning(const Logger* logger) override;
100
103 LoggerPtr exists(const LogString& name) override;
104
107 void setThreshold(const LogString& levelStr) override;
108
111 void setThreshold(const LevelPtr& newLevel) override;
112
115 void fireAddAppenderEvent(const Logger* logger, const Appender* appender) override;
116
119 void fireRemoveAppenderEvent(const Logger* logger, const Appender* appender) override;
120
123 LevelPtr getThreshold() const override;
124
128 const spi::LoggerFactoryPtr& factory = {}) override;
129
132 LoggerList getCurrentLoggers() const override;
133
136 LoggerPtr getRootLogger() const override;
137
140 bool isDisabled(int level) const override;
141
144 void resetConfiguration() override;
145
155 void shutdown() override;
156
159 virtual bool isConfigured() override;
160
163 virtual void setConfigured(bool configured) override;
164
167 void updateChildren(const Logger* parent) override;
168
171 bool removeLogger(const LogString& name, bool ifNotUsed = true) override;
172
173 private:
174
178 void setThresholdInternal(const LevelPtr& l);
179
183 void shutdownInternal();
184
208 void updateParents(const LoggerPtr& logger, const LoggerPtr& root);
209
219 void updateAncestory(ProvisionNode& pn, const LoggerPtr& logger);
220
221 Hierarchy(const Hierarchy&);
222 Hierarchy& operator=(const Hierarchy&);
223
224};
225
226} //namespace log4cxx
227
228#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 and configurator has not already been tried....
bool removeLogger(const LogString &name, bool ifNotUsed=true) override
Remove the name Logger from the repository.Note: The name Logger must be retrieved from the repositor...
LoggerList getCurrentLoggers() const override
All the loggers currently defined in this repository.The root logger is not included in the returned ...
void emitNoAppenderWarning(const Logger *logger) override
Add a warning to internal debug output that logger does not have any Appender attached.
LoggerPtr getRootLogger() const override
The logger that cannot be retrieved by name.
void resetConfiguration() override
Reset all values contained in this repository instance to their default.This removes all appenders fr...
LevelPtr getThreshold() const override
The current repository-wide threshold.See setThreshold for an explanation.
LoggerPtr exists(const LogString &name) override
Does name exist in the repository?The Logger instance if name exists in the repository.
void removeHierarchyEventListener(const spi::HierarchyEventListenerPtr &listener) override
Remove listener from the repository.
void setThreshold(const LevelPtr &newLevel) override
Enable logging for logging requests with level newLevel or higher.All logging requests below the thre...
virtual void setConfigured(bool configured) override
Set the configured status to true.
void fireAddAppenderEvent(const Logger *logger, const Appender *appender) override
Call addAppenderEvent on all registered listeners.
void updateChildren(const Logger *parent) override
Refresh the configuration of all loggers where parent is somewhere in their ancestor chain....
static HierarchyPtr create()
Create a new logger hierarchy.
bool isDisabled(int level) const override
Is the repository disabled for level?The answer depends on the repository threshold and the level par...
virtual bool isConfigured() override
The value of the configured status.
void addHierarchyEventListener(const spi::HierarchyEventListenerPtr &listener) override
LoggerPtr getLogger(const LogString &name, const spi::LoggerFactoryPtr &factory={}) override
Retrieve the name Logger instance.If a logger of that name already exists, it will be returned....
void clear()
This call will clear all logger definitions from the internal hashtable.
void setThreshold(const LogString &levelStr) override
Enable logging for logging requests with level newLevel or higher.The threshold is set the DEBUG if n...
void fireRemoveAppenderEvent(const Logger *logger, const Appender *appender) override
Call removeAppenderEvent on all registered listeners.
void shutdown() override
Shutting down a hierarchy will safely close and remove all appenders in all categories including the ...
This is the central class in the log4cxx package.
Definition log4cxx/logger.h:52
A LoggerRepository is used to create and retrieve Loggers.
Definition loggerrepository.h:43
std::vector< LoggerPtr > ProvisionNode
Definition provisionnode.h:31
std::basic_string< logchar > LogString
Definition logstring.h:51
std::shared_ptr< Level > LevelPtr
Definition optionconverter.h:28
LOG4CXX_PTR_DEF(Appender)
std::shared_ptr< Logger > LoggerPtr
Definition provisionnode.h:28
#define LOG4CXX_CAST_ENTRY(Interface)
Definition object.h:153
#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)
Definition object.h:37
#define END_LOG4CXX_CAST_MAP()
Definition object.h:147
#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)
Definition object.h:159
#define BEGIN_LOG4CXX_CAST_MAP()
Definition object.h:141