Apache Log4cxx  Version 1.5.0
logmanager.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_LOG_MANAGER_H
19 #define _LOG4CXX_LOG_MANAGER_H
20 
21 #include <log4cxx/logstring.h>
22 #include <vector>
24 
25 namespace LOG4CXX_NS
26 {
27 class Logger;
28 typedef std::shared_ptr<Logger> LoggerPtr;
29 typedef std::vector<LoggerPtr> LoggerList;
30 
31 namespace spi
32 {
33 class LoggerFactory;
34 typedef std::shared_ptr<LoggerFactory> LoggerFactoryPtr;
35 }
36 
44 class LOG4CXX_EXPORT LogManager
45 {
46  private:
47  static void* guard;
48  static spi::RepositorySelectorPtr getRepositorySelector();
49 
50  public:
67  static void setRepositorySelector(spi::RepositorySelectorPtr selector,
68  void* guard);
69 
71 
79 
88  static LoggerPtr getLogger(const std::string& name);
89 
98  static LoggerPtr getLogger(const std::string& name,
99  const spi::LoggerFactoryPtr& factory);
105  static LoggerPtr exists(const std::string& name);
106 #if LOG4CXX_WCHAR_T_API
107 
115  static LoggerPtr getLogger(const std::wstring& name);
124  static LoggerPtr getLogger(const std::wstring& name,
125  const spi::LoggerFactoryPtr& factory);
131  static LoggerPtr exists(const std::wstring& name);
132 #endif
133 #if LOG4CXX_UNICHAR_API
134 
143  static LoggerPtr getLogger(const std::basic_string<UniChar>& name);
153  static LoggerPtr getLogger(const std::basic_string<UniChar>& name,
154  const spi::LoggerFactoryPtr& factory);
160  static LoggerPtr exists(const std::basic_string<UniChar>& name);
161 #endif
162 #if LOG4CXX_CFSTRING_API
163 
172  static LoggerPtr getLogger(const CFStringRef& name);
182  static LoggerPtr getLogger(const CFStringRef& name,
183  const spi::LoggerFactoryPtr& factory);
189  static LoggerPtr exists(const CFStringRef& name);
190 #endif
191 
192 
202  static LoggerPtr getLoggerLS(const LogString& name);
212  static LoggerPtr getLoggerLS(const LogString& name,
213  const spi::LoggerFactoryPtr& factory);
214 
220  static LoggerPtr existsLS(const LogString& name);
221 
223 
228  static void shutdown();
229 
235  static void resetConfiguration();
236 
248  static bool removeLogger(const LogString& name, bool ifNotUsed = true);
249 }; // class LogManager
250 } // namespace log4cxx
251 
252 
253 #endif //_LOG4CXX_LOG_MANAGER_H
logstring.h
log4cxx::spi::LoggerRepositoryPtr
std::shared_ptr< LoggerRepository > LoggerRepositoryPtr
Definition: optionconverter.h:32
log4cxx::LogString
std::basic_string< logchar > LogString
Definition: logstring.h:60
log4cxx::LogManager::getLogger
static LoggerPtr getLogger(const CFStringRef &name, const spi::LoggerFactoryPtr &factory)
Retrieve the name Logger instance from the LoggerRepository using factory to create it if required.
log4cxx::LogManager::resetConfiguration
static void resetConfiguration()
Reset all values contained in this current LoggerRepository to their default.
log4cxx::LogManager::getCurrentLoggers
static LoggerList getCurrentLoggers()
log4cxx::LogManager::getLoggerRepository
static spi::LoggerRepositoryPtr getLoggerRepository()
log4cxx::LogManager::getLogger
static LoggerPtr getLogger(const std::string &name, const spi::LoggerFactoryPtr &factory)
Retrieve the name Logger instance from the LoggerRepository using factory to create it if required.
log4cxx::LogManager::getRootLogger
static LoggerPtr getRootLogger()
Retrieve the root logger from the LoggerRepository.
log4cxx::LogManager::exists
static LoggerPtr exists(const CFStringRef &name)
A pointer to the Logger name instance if it exists in the LoggerRepository.
CFStringRef
const struct __CFString * CFStringRef
Definition: logstring.h:30
log4cxx::LogManager::getLoggerLS
static LoggerPtr getLoggerLS(const LogString &name)
Retrieve the name Logger instance from the LoggerRepository using the default factory to create it if...
log4cxx::LogManager::setRepositorySelector
static void setRepositorySelector(spi::RepositorySelectorPtr selector, void *guard)
Use selector to source the LoggerRepository, but only if the correct guard is passed as parameter.
log4cxx::LogManager::getLogger
static LoggerPtr getLogger(const std::wstring &name, const spi::LoggerFactoryPtr &factory)
Retrieve the name Logger instance from the LoggerRepository using factory to create it if required.
log4cxx::LogManager::getLogger
static LoggerPtr getLogger(const CFStringRef &name)
Retrieve the name Logger instance from the LoggerRepository using the default factory to create it if...
log4cxx::LoggerList
std::vector< LoggerPtr > LoggerList
Definition: logmanager.h:29
log4cxx::LogManager
Use the LogManager class to retreive Logger instances or to operate on the current LoggerRepository.
Definition: logmanager.h:45
log4cxx::LogManager::shutdown
static void shutdown()
Safely close and remove all appenders in all loggers including the root logger.
log4cxx::LogManager::existsLS
static LoggerPtr existsLS(const LogString &name)
A pointer to the Logger name instance if it exists in the LoggerRepository.
log4cxx::LogManager::exists
static LoggerPtr exists(const std::basic_string< UniChar > &name)
A pointer to the Logger name instance if it exists in the LoggerRepository.
log4cxx::spi::LoggerFactoryPtr
std::shared_ptr< LoggerFactory > LoggerFactoryPtr
Definition: logmanager.h:33
log4cxx::LogManager::exists
static LoggerPtr exists(const std::string &name)
A pointer to the Logger name instance if it exists in the LoggerRepository.
log4cxx::LogManager::getLoggerLS
static LoggerPtr getLoggerLS(const LogString &name, const spi::LoggerFactoryPtr &factory)
Retrieve the name Logger instance from the LoggerRepository using factory to create it if required.
log4cxx::LogManager::getLogger
static LoggerPtr getLogger(const std::wstring &name)
Retrieve the name Logger instance from the LoggerRepository using the default factory to create it if...
repositoryselector.h
log4cxx::LogManager::removeLogger
static bool removeLogger(const LogString &name, bool ifNotUsed=true)
Remove the name Logger from the LoggerRepository.
log4cxx::LogManager::exists
static LoggerPtr exists(const std::wstring &name)
A pointer to the Logger name instance if it exists in the LoggerRepository.
log4cxx::LoggerPtr
std::shared_ptr< Logger > LoggerPtr
Definition: defaultloggerfactory.h:26
log4cxx::LogManager::getLogger
static LoggerPtr getLogger(const std::basic_string< UniChar > &name, const spi::LoggerFactoryPtr &factory)
Retrieve the name Logger instance from the LoggerRepository using factory to create it if required.
log4cxx::LogManager::getLogger
static LoggerPtr getLogger(const std::basic_string< UniChar > &name)
Retrieve the name Logger instance from the LoggerRepository using the default factory to create it if...
log4cxx::LogManager::getLogger
static LoggerPtr getLogger(const std::string &name)
Retrieve the name Logger instance from the LoggerRepository using the default factory to create it if...