RSC  0.10.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LoggerFactory.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of RSC project
4  *
5  * Copyright (C) 2010 by Johannes Wienke <jwienke at techfak dot uni-bielefeld dot de>
6  *
7  * This file may be licensed under the terms of the
8  * GNU Lesser General Public License Version 3 (the ``LGPL''),
9  * or (at your option) any later version.
10  *
11  * Software distributed under the License is distributed
12  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
13  * express or implied. See the LGPL for the specific language
14  * governing rights and limitations.
15  *
16  * You should have received a copy of the LGPL along with this
17  * program. If not, go to http://www.gnu.org/licenses/lgpl.html
18  * or write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  * The development of this software was supported by:
22  * CoR-Lab, Research Institute for Cognition and Robotics
23  * Bielefeld University
24  *
25  * ============================================================ */
26 
27 #pragma once
28 
29 #include <map>
30 #include <vector>
31 
32 #include <boost/noncopyable.hpp>
33 #include <boost/thread/recursive_mutex.hpp>
34 #include <boost/weak_ptr.hpp>
35 #include <boost/shared_ptr.hpp>
36 
37 #include "Logger.h"
38 #include "LoggerTreeNode.h"
39 #include "LoggerProxy.h"
40 #include "LoggingSystem.h"
41 #include "../misc/Registry.h"
42 #include "../patterns/Singleton.h"
43 #include "../misc/langutils.h"
44 #include "rsc/rscexports.h"
45 
46 namespace rsc {
47 
77 namespace logging {
78 
85 class RSC_EXPORT LoggerFactory: public patterns::Singleton<LoggerFactory> {
86 private:
87  LoggerFactory();
88 
89 public:
90 
92 
93  virtual ~LoggerFactory();
94 
106  LoggerPtr getLogger(const std::string& name = "");
107 
118  void reconfigure(const Logger::Level& level);
119 
126  void reconfigureFromFile(const std::string& fileName);
127 
145  void reselectLoggingSystem(const std::string& nameHint = "");
146 
151  static const std::string DEFAULT_LOGGING_SYSTEM;
152 
157 
163  std::string getLoggingSystemName();
164 
168  void clearKnownLoggers();
169 
170 private:
171 
173  class ReselectVisitor;
174 
175  LoggerProxyPtr createLogger(const LoggerTreeNode::NamePath& path,
176  LoggerTreeNodePtr node);
177 
178  boost::shared_ptr<LoggingSystem> loggingSystem;
179 
180  boost::recursive_mutex mutex;
182 
183 };
184 
185 }
186 }
187 
boost::shared_ptr< LoggerProxy > LoggerProxyPtr
Definition: LoggerProxy.h:112
std::vector< std::string > NamePath
A unique representation of a name.
Level
Possible logging levels.
Definition: Logger.h:63
boost::recursive_mutex mutex
This template class implements the singleton pattern.
Definition: Singleton.h:51
boost::shared_ptr< LoggingSystem > loggingSystem
LoggerPtr getLogger()
boost::shared_ptr< LoggerTreeNode > LoggerTreeNodePtr
Factory to create logger instances.
Definition: LoggerFactory.h:85
LoggerTreeNodePtr loggerTree
static const Logger::Level DEFAULT_LEVEL
Default level when the system is used without prior initialization.
static const std::string DEFAULT_LOGGING_SYSTEM
Parameter to pass as name hint to reselectLoggingSystem for selecting the default system...
boost::shared_ptr< Logger > LoggerPtr
Definition: Logger.h:41