RSC  0.19.0
ConsoleLoggingSystem.cpp
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is part of the 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 #include "ConsoleLoggingSystem.h"
29 
30 #if defined(__linux__) or defined(__APPLE__)
31 #include <unistd.h>
32 #endif
33 
34 #include "ConsoleLogger.h"
35 #include "SGRConsoleLogger.h"
36 
37 namespace rsc {
38 namespace logging {
39 
41 #if defined(__linux__) or defined(__APPLE__)
42  canUseSGRs(isatty(1) && isatty(2))
43 #else
44  canUseSGRs(false)
45 #endif
46 {
47 }
48 
50 }
51 
52 const std::string ConsoleLoggingSystem::getName() const {
53  return "ConsoleLoggingSystem";
54 }
55 
57  if (this->canUseSGRs) {
58  return LoggerPtr(new SGRConsoleLogger(name));
59  } else {
60  return LoggerPtr(new ConsoleLogger(name));
61  }
62 }
63 
65  return new ConsoleLoggingSystem();
66 }
67 
68 }
69 }
A simple logger that uses cout and cerr for logging.
Definition: ConsoleLogger.h:45
static ConsoleLoggingSystem * create(const runtime::Properties &properties)
const std::string getName() const
Return the name of the logging system.
Default logging system using the console for output.
LoggerPtr createLogger(const std::string &name)
Factory method to create a new system-specific logger.
if(INIT_METHOD_ATTRIBUTE_CONSTRUCTOR) set(INIT_METHOD_NAME RSC_HAVE_INIT_METHOD_ATTRIBUTE_CONSTRUCTOR) elseif(INIT_METHOD_CRT) set(INIT_METHOD_NAME RSC_HAVE_INIT_METHOD_CRT) else() set(INIT_METHOD_NAME RSC_HAVE_NO_INIT_METHOD_ERROR) endif() string(REPLACE".""_"RSC_EXPORTS_NAME $
Definition: CMakeLists.txt:3
Properties objects are basically glorified map<string, boost::any> objects.
Definition: Properties.h:57
boost::shared_ptr< Logger > LoggerPtr
Definition: Logger.h:41