RSC  0.19.0
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  * Copyright (C) 2018 Jan Moringen <jmoringe@techfak.uni-bielefeld.de>
7  *
8  * This file may be licensed under the terms of the
9  * GNU Lesser General Public License Version 3 (the ``LGPL''),
10  * or (at your option) any later version.
11  *
12  * Software distributed under the License is distributed
13  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14  * express or implied. See the LGPL for the specific language
15  * governing rights and limitations.
16  *
17  * You should have received a copy of the LGPL along with this
18  * program. If not, go to http://www.gnu.org/licenses/lgpl.html
19  * or write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  * The development of this software was supported by:
23  * CoR-Lab, Research Institute for Cognition and Robotics
24  * Bielefeld University
25  *
26  * ============================================================ */
27 
28 #pragma once
29 
30 #include <boost/thread/recursive_mutex.hpp>
31 
32 #include "../patterns/Singleton.h"
33 
34 #include "Logger.h"
35 #include "LoggerTreeNode.h"
36 #include "LoggerProxy.h"
37 #include "LoggingSystem.h"
38 
39 #include "rsc/rscexports.h"
40 
41 namespace rsc {
42 
73 namespace logging {
74 
81 class RSC_EXPORT LoggerFactory: public patterns::Singleton<LoggerFactory> {
82 private:
83  LoggerFactory();
84 
85 public:
86 
88 
89  virtual ~LoggerFactory();
90 
102  LoggerPtr getLogger(const std::string& name = "");
103 
114  void reconfigure(const Logger::Level& level);
115 
122  void reconfigureFromFile(const std::string& fileName);
123 
141  void reselectLoggingSystem(const std::string& nameHint = "");
142 
147  static const std::string DEFAULT_LOGGING_SYSTEM;
148 
153 
159  std::string getLoggingSystemName();
160 
164  void clearKnownLoggers();
165 
166 private:
167 
169  class ReselectVisitor;
170 
171  LoggerProxyPtr createLogger(const LoggerTreeNode::NamePath& path,
172  LoggerTreeNodePtr node);
173 
175 
176  boost::recursive_mutex mutex;
178 
179 };
180 
181 }
182 }
boost::shared_ptr< LoggerProxy > LoggerProxyPtr
Definition: LoggerProxy.h:112
LoggingSystemPtr loggingSystem
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
LoggerPtr getLogger()
boost::shared_ptr< LoggingSystem > LoggingSystemPtr
Definition: LoggingSystem.h:73
boost::shared_ptr< LoggerTreeNode > LoggerTreeNodePtr
Factory to create logger instances.
Definition: LoggerFactory.h:81
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