RSC  0.7.17
 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 
69 namespace logging {
70 
77 class RSC_EXPORT LoggerFactory: public patterns::Singleton<LoggerFactory> {
78 private:
79  LoggerFactory();
80 
81 public:
82 
84 
85  virtual ~LoggerFactory();
86 
98  LoggerPtr getLogger(const std::string& name = "");
99 
110  void reconfigure(const Logger::Level& level);
111 
118  void reconfigureFromFile(const std::string& fileName);
119 
137  void reselectLoggingSystem(const std::string& nameHint = "");
138 
143  static const std::string DEFAULT_LOGGING_SYSTEM;
144 
149 
155  std::string getLoggingSystemName();
156 
160  void clearKnownLoggers();
161 
162 private:
163 
165  class ReselectVisitor;
166 
167  LoggerProxyPtr createLogger(const LoggerTreeNode::NamePath& path,
168  LoggerTreeNodePtr node);
169 
170  boost::shared_ptr<LoggingSystem> loggingSystem;
171 
172  boost::recursive_mutex mutex;
174 
175 };
176 
177 }
178 }
179 
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
boost::shared_ptr< LoggerTreeNode > LoggerTreeNodePtr
Factory to create logger instances.
Definition: LoggerFactory.h:77
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