diff options
author | Stefan Radomski <github@mintwerk.de> | 2016-12-09 12:25:11 (GMT) |
---|---|---|
committer | Stefan Radomski <github@mintwerk.de> | 2016-12-09 12:25:11 (GMT) |
commit | 9b8e09c3fde755ec26e5c21b9640f53ed9329d05 (patch) | |
tree | c7001e5bfc551a24e3cee0b3fb014791e0685b44 /src/uscxml/interpreter | |
parent | 9fae96bbf295fcd867d60bf45d9c3b825ae692c2 (diff) | |
download | uscxml-9b8e09c3fde755ec26e5c21b9640f53ed9329d05.zip uscxml-9b8e09c3fde755ec26e5c21b9640f53ed9329d05.tar.gz uscxml-9b8e09c3fde755ec26e5c21b9640f53ed9329d05.tar.bz2 |
Removed easylogging due to JNI segfaults
Diffstat (limited to 'src/uscxml/interpreter')
-rw-r--r-- | src/uscxml/interpreter/BasicContentExecutor.cpp | 2 | ||||
-rw-r--r-- | src/uscxml/interpreter/BasicEventQueue.cpp | 2 | ||||
-rw-r--r-- | src/uscxml/interpreter/FastMicroStep.cpp | 2 | ||||
-rw-r--r-- | src/uscxml/interpreter/InterpreterImpl.cpp | 2 | ||||
-rw-r--r-- | src/uscxml/interpreter/Logging.cpp | 99 | ||||
-rw-r--r-- | src/uscxml/interpreter/Logging.h | 96 | ||||
-rw-r--r-- | src/uscxml/interpreter/LoggingImpl.h | 54 | ||||
-rw-r--r-- | src/uscxml/interpreter/StdOutLogger.cpp | 41 | ||||
-rw-r--r-- | src/uscxml/interpreter/StdOutLogger.h | 43 |
9 files changed, 337 insertions, 4 deletions
diff --git a/src/uscxml/interpreter/BasicContentExecutor.cpp b/src/uscxml/interpreter/BasicContentExecutor.cpp index a2ebc5c..1cf9c2f 100644 --- a/src/uscxml/interpreter/BasicContentExecutor.cpp +++ b/src/uscxml/interpreter/BasicContentExecutor.cpp @@ -29,7 +29,7 @@ #include <xercesc/sax/HandlerBase.hpp> #include <xercesc/framework/MemBufInputSource.hpp> -#include "easylogging++.h" +#include "uscxml/interpreter/Logging.h" namespace uscxml { diff --git a/src/uscxml/interpreter/BasicEventQueue.cpp b/src/uscxml/interpreter/BasicEventQueue.cpp index 78b2321..04ffc7c 100644 --- a/src/uscxml/interpreter/BasicEventQueue.cpp +++ b/src/uscxml/interpreter/BasicEventQueue.cpp @@ -22,7 +22,7 @@ #include <event2/thread.h> #include <assert.h> -#include <easylogging++.h> +#include "uscxml/interpreter/Logging.h" namespace uscxml { diff --git a/src/uscxml/interpreter/FastMicroStep.cpp b/src/uscxml/interpreter/FastMicroStep.cpp index 90b93ee..8711b62 100644 --- a/src/uscxml/interpreter/FastMicroStep.cpp +++ b/src/uscxml/interpreter/FastMicroStep.cpp @@ -26,7 +26,7 @@ #include "uscxml/util/Convenience.h" #include "uscxml/interpreter/InterpreterMonitor.h" -#include <easylogging++.h> +#include "uscxml/interpreter/Logging.h" #define BIT_ANY_SET(b) (!b.none()) #define BIT_HAS(idx, bitset) (bitset[idx]) diff --git a/src/uscxml/interpreter/InterpreterImpl.cpp b/src/uscxml/interpreter/InterpreterImpl.cpp index d3b044a..7b79988 100644 --- a/src/uscxml/interpreter/InterpreterImpl.cpp +++ b/src/uscxml/interpreter/InterpreterImpl.cpp @@ -28,7 +28,7 @@ #include "uscxml/util/Predicates.h" #include "uscxml/plugins/InvokerImpl.h" -#include "easylogging++.h" +#include "uscxml/interpreter/Logging.h" #include <iostream> diff --git a/src/uscxml/interpreter/Logging.cpp b/src/uscxml/interpreter/Logging.cpp new file mode 100644 index 0000000..bdb847a --- /dev/null +++ b/src/uscxml/interpreter/Logging.cpp @@ -0,0 +1,99 @@ +/** + * @file + * @author 2016 Stefan Radomski (stefan.radomski@cs.tu-darmstadt.de) + * @copyright Simplified BSD + * + * @cond + * This program is free software: you can redistribute it and/or modify + * it under the terms of the FreeBSD license as published by the FreeBSD + * project. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the FreeBSD license along with this + * program. If not, see <http://www.opensource.org/licenses/bsd-license>. + * @endcond + */ + +#include "Logging.h" +#include "LoggingImpl.h" + +// for default logger +#include "StdOutLogger.h" + +namespace uscxml { + +std::shared_ptr<LoggerImpl> LoggerImpl::_defaultLogger; + +std::shared_ptr<LoggerImpl> LoggerImpl::getDefault() { + if (!_defaultLogger) + _defaultLogger = std::shared_ptr<LoggerImpl>(new StdOutLogger()); + return _defaultLogger; +} + +Logger Logger::getDefault() { + return LoggerImpl::getDefault(); +} + +void log(LogSeverity severity, const Event& event) { + LoggerImpl::getDefault()->log(severity, event); +} + +void log(LogSeverity severity, const Data& data) { + LoggerImpl::getDefault()->log(severity, data); +} + +void Logger::log(LogSeverity severity, const Event& event) { + _impl->log(severity, event); +} + +void Logger::log(LogSeverity severity, const Data& data) { + _impl->log(severity, data); +} + +void Logger::log(LogSeverity severity, const std::string& message) { + _impl->log(severity, message); +} + +StreamLogger Logger::log(LogSeverity severity) { + return StreamLogger(severity, _impl); +} + +StreamLogger::~StreamLogger() { + _logger->log(_severity, ss.str()); +} + +std::shared_ptr<LoggerImpl> Logger::getImpl() const { + return _impl; +} + +std::ostream& StreamLogger::operator<<(const std::string& message) { + ss << message; //_logger->log(_severity, event); + return ss; +} + +std::string Logger::severityToString(LogSeverity severity) { + switch (severity) { + case USCXML_SCXML: + return "Interpreter"; + case USCXML_TRACE: + return "Trace"; + case USCXML_DEBUG: + return "Debug"; + case USCXML_INFO: + return "Info"; + case USCXML_WARN: + return "Warning"; + case USCXML_ERROR: + return "Error"; + case USCXML_FATAL: + return "Fatal"; + default: + return "Unknown"; + + } +} + +} diff --git a/src/uscxml/interpreter/Logging.h b/src/uscxml/interpreter/Logging.h new file mode 100644 index 0000000..7746998 --- /dev/null +++ b/src/uscxml/interpreter/Logging.h @@ -0,0 +1,96 @@ +/** + * @file + * @author 2016 Stefan Radomski (stefan.radomski@cs.tu-darmstadt.de) + * @copyright Simplified BSD + * + * @cond + * This program is free software: you can redistribute it and/or modify + * it under the terms of the FreeBSD license as published by the FreeBSD + * project. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the FreeBSD license along with this + * program. If not, see <http://www.opensource.org/licenses/bsd-license>. + * @endcond + */ + +#ifndef LOGGING_H_3B1A3A0F +#define LOGGING_H_3B1A3A0F + +#include "uscxml/config.h" +#include "uscxml/Common.h" + +#include "uscxml/messages/Data.h" +#include "uscxml/messages/Event.h" + +#include <memory> + +#define LOG(lvl) uscxml::Logger::getDefault().log(lvl) +#define LOG2(lvl, thing) uscxml::Logger::getDefault().log(lvl, thing); + +#define SCXML USCXML_SCXML +#define TRACE USCXML_TRACE +#define DEBUG USCXML_DEBUG +#define INFO USCXML_INFO +#define WARNING USCXML_WARN +#define ERROR USCXML_ERROR +#define FATAL USCXML_FATAL + +namespace uscxml { + +enum LogSeverity { + USCXML_SCXML, + USCXML_TRACE, + USCXML_DEBUG, + USCXML_INFO, + USCXML_WARN, + USCXML_ERROR, + USCXML_FATAL +}; + +class LoggerImpl; + +void log(LogSeverity severity, const Event& event); +void log(LogSeverity severity, const Data& data); + +class StreamLogger { +public: + std::ostream& operator<<(const std::string& message); + ~StreamLogger(); + +protected: + StreamLogger(LogSeverity severity, std::shared_ptr<LoggerImpl> logger) : _severity(severity), _logger(logger) {} + StreamLogger(const StreamLogger& other) : _severity(other._severity), _logger(other._logger) {} + + LogSeverity _severity; + std::shared_ptr<LoggerImpl> _logger; + std::stringstream ss; + + friend class Logger; +}; + +class USCXML_API Logger { +public: + PIMPL_OPERATORS(Logger); + + virtual void log(LogSeverity severity, const Event& event); + virtual void log(LogSeverity severity, const Data& data); + virtual void log(LogSeverity severity, const std::string& message); + + virtual StreamLogger log(LogSeverity severity); + static std::string severityToString(LogSeverity severity); + + static Logger getDefault(); + + std::shared_ptr<LoggerImpl> getImpl() const; +protected: + std::shared_ptr<LoggerImpl> _impl; + +}; + +} + +#endif /* end of include guard: LOGGING_H_3B1A3A0F */ diff --git a/src/uscxml/interpreter/LoggingImpl.h b/src/uscxml/interpreter/LoggingImpl.h new file mode 100644 index 0000000..c6003ca --- /dev/null +++ b/src/uscxml/interpreter/LoggingImpl.h @@ -0,0 +1,54 @@ +/** + * @file + * @author 2016 Stefan Radomski (stefan.radomski@cs.tu-darmstadt.de) + * @copyright Simplified BSD + * + * @cond + * This program is free software: you can redistribute it and/or modify + * it under the terms of the FreeBSD license as published by the FreeBSD + * project. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the FreeBSD license along with this + * program. If not, see <http://www.opensource.org/licenses/bsd-license>. + * @endcond + */ + +#ifndef LOGGINGIMPL_H_CF00F49B +#define LOGGINGIMPL_H_CF00F49B + +#include "uscxml/config.h" +#include "uscxml/Common.h" + +#include "Logging.h" + +#include "uscxml/messages/Data.h" +#include "uscxml/messages/Event.h" + +namespace uscxml { + +/** +* @ingroup impl +*/ +class USCXML_API LoggerImpl { +public: + + LoggerImpl() {} + virtual std::shared_ptr<LoggerImpl> create() = 0; + + virtual void log(LogSeverity severity, const Event& event) = 0; + virtual void log(LogSeverity severity, const Data& data) = 0; + virtual void log(LogSeverity severity, const std::string& message) = 0; + + static std::shared_ptr<LoggerImpl> getDefault(); + +private: + static std::shared_ptr<LoggerImpl> _defaultLogger; +}; + +} + +#endif /* end of include guard: LOGGINGIMPL_H_CF00F49B */ diff --git a/src/uscxml/interpreter/StdOutLogger.cpp b/src/uscxml/interpreter/StdOutLogger.cpp new file mode 100644 index 0000000..1794c1f --- /dev/null +++ b/src/uscxml/interpreter/StdOutLogger.cpp @@ -0,0 +1,41 @@ +/** + * @file + * @author 2016 Stefan Radomski (stefan.radomski@cs.tu-darmstadt.de) + * @copyright Simplified BSD + * + * @cond + * This program is free software: you can redistribute it and/or modify + * it under the terms of the FreeBSD license as published by the FreeBSD + * project. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the FreeBSD license along with this + * program. If not, see <http://www.opensource.org/licenses/bsd-license>. + * @endcond + */ + +#include "StdOutLogger.h" +#include <iostream> + +namespace uscxml { + +std::shared_ptr<LoggerImpl> StdOutLogger::create() { + return std::shared_ptr<LoggerImpl>(new StdOutLogger()); +} + +void StdOutLogger::log(LogSeverity severity, const std::string& message) { + std::cout << Logger::severityToString(severity) << ": " << message << std::endl; +} + +void StdOutLogger::log(LogSeverity severity, const Event& event) { + std::cout << Logger::severityToString(severity) << ": " << event << std::endl; +} + +void StdOutLogger::log(LogSeverity severity, const Data& data) { + std::cout << Logger::severityToString(severity) << ": " << data << std::endl; +} + +} diff --git a/src/uscxml/interpreter/StdOutLogger.h b/src/uscxml/interpreter/StdOutLogger.h new file mode 100644 index 0000000..fbc006f --- /dev/null +++ b/src/uscxml/interpreter/StdOutLogger.h @@ -0,0 +1,43 @@ +/** + * @file + * @author 2016 Stefan Radomski (stefan.radomski@cs.tu-darmstadt.de) + * @copyright Simplified BSD + * + * @cond + * This program is free software: you can redistribute it and/or modify + * it under the terms of the FreeBSD license as published by the FreeBSD + * project. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the FreeBSD license along with this + * program. If not, see <http://www.opensource.org/licenses/bsd-license>. + * @endcond + */ + +#ifndef STDOUTLOGGER_H_1A28C761 +#define STDOUTLOGGER_H_1A28C761 + +#include "LoggingImpl.h" + +namespace uscxml { + +class USCXML_API StdOutLogger : public LoggerImpl { +public: + StdOutLogger() {} + virtual ~StdOutLogger() {} + + virtual std::shared_ptr<LoggerImpl> create(); + + virtual void log(LogSeverity severity, const std::string& message); + virtual void log(LogSeverity severity, const Event& event); + virtual void log(LogSeverity severity, const Data& data); + +}; + + +} + +#endif /* end of include guard: STDOUTLOGGER_H_1A28C761 */ |