summaryrefslogtreecommitdiffstats
path: root/src/uscxml
diff options
context:
space:
mode:
authorStefan Radomski <github@mintwerk.de>2016-12-12 16:17:09 (GMT)
committerStefan Radomski <github@mintwerk.de>2016-12-12 16:17:09 (GMT)
commit7c5b4e84a2bf276de58db70f4996f5955e18057e (patch)
tree991c147c775c6540797e9527ccbcebdff87fcb0b /src/uscxml
parent047a35fc691a348008cbfbf4c3d7722a6ec4f93e (diff)
downloaduscxml-7c5b4e84a2bf276de58db70f4996f5955e18057e.zip
uscxml-7c5b4e84a2bf276de58db70f4996f5955e18057e.tar.gz
uscxml-7c5b4e84a2bf276de58db70f4996f5955e18057e.tar.bz2
DebugSession implements new Logger ABC
Diffstat (limited to 'src/uscxml')
-rw-r--r--src/uscxml/debug/DebugSession.cpp65
-rw-r--r--src/uscxml/debug/DebugSession.h11
-rw-r--r--src/uscxml/debug/DebuggerServlet.cpp17
-rw-r--r--src/uscxml/debug/DebuggerServlet.h9
4 files changed, 76 insertions, 26 deletions
diff --git a/src/uscxml/debug/DebugSession.cpp b/src/uscxml/debug/DebugSession.cpp
index fff6fe1..9fa09eb 100644
--- a/src/uscxml/debug/DebugSession.cpp
+++ b/src/uscxml/debug/DebugSession.cpp
@@ -415,5 +415,70 @@ Data DebugSession::debugEval(const Data& data) {
return replyData;
}
+std::shared_ptr<LoggerImpl> DebugSession::create() {
+ return shared_from_this();
+}
+
+void DebugSession::log(LogSeverity severity, const Event& event) {
+ Data d;
+ d.compound["data"] = event.data;
+ d.compound["name"] = Data(event.name);
+ d.compound["origin"] = Data(event.origin);
+ d.compound["origintype"] = Data(event.origintype);
+
+ switch (event.eventType) {
+ case Event::Type::INTERNAL:
+ d.compound["eventType"] = Data("INTERNAL");
+ break;
+ case Event::Type::EXTERNAL:
+ d.compound["eventType"] = Data("EXTERNAL");
+ break;
+ case Event::Type::PLATFORM:
+ d.compound["eventType"] = Data("PLATFORM");
+ break;
+ default:
+ break;
+ }
+ if (!event.hideSendId)
+ d.compound["sendid"] = Data(event.sendid);
+ if (event.invokeid.size() > 0)
+ d.compound["invokeid"] = Data(event.invokeid);
+
+ // handle params
+ Data& params = d.compound["params"];
+ bool convertedToArray = false;
+ for (auto param : event.params) {
+ if (params.compound.find(param.first) != d.compound.end()) {
+ // no such key, add as literal data
+ d.compound[param.first] = param.second;
+ } else if (params.compound[param.first].array.size() > 0 && convertedToArray) {
+ // key is already an array
+ params.compound[param.first].array.push_back(param.second);
+ } else {
+ // key already given as literal data, move to array
+ Data& existingParam = params.compound[param.first];
+ params.compound[param.first].array.push_back(existingParam);
+ params.compound[param.first].array.push_back(param.second);
+ params.compound[param.first].compound.clear();
+ convertedToArray = true;
+ }
+ }
+
+ // handle namelist
+ Data& namelist = d.compound["namelist"];
+ for (auto name : event.namelist) {
+ namelist.compound[name.first] = name.second;
+ }
+
+ _debugger->pushData(shared_from_this(), d);
+}
+
+void DebugSession::log(LogSeverity severity, const Data& data) {
+ _debugger->pushData(shared_from_this(), data);
+}
+
+void DebugSession::log(LogSeverity severity, const std::string& message) {
+ _debugger->pushData(shared_from_this(), Data(message));
+}
}
diff --git a/src/uscxml/debug/DebugSession.h b/src/uscxml/debug/DebugSession.h
index fbfd065..c5ed7e5 100644
--- a/src/uscxml/debug/DebugSession.h
+++ b/src/uscxml/debug/DebugSession.h
@@ -22,6 +22,8 @@
#include "uscxml/debug/Breakpoint.h"
#include "uscxml/Interpreter.h"
+#include "uscxml/interpreter/LoggingImpl.h"
+
#include <time.h>
#include <set>
#include <thread>
@@ -31,7 +33,7 @@ namespace uscxml {
class Debugger;
-class USCXML_API DebugSession : public std::enable_shared_from_this<DebugSession> {
+class USCXML_API DebugSession : public LoggerImpl ,public std::enable_shared_from_this<DebugSession> {
public:
DebugSession() {
_isRunning = false;
@@ -77,6 +79,13 @@ public:
_markedForDeletion = mark;
}
+ // Logger
+ virtual std::shared_ptr<LoggerImpl> create();
+
+ 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);
+
protected:
void breakExecution(Data replyData);
diff --git a/src/uscxml/debug/DebuggerServlet.cpp b/src/uscxml/debug/DebuggerServlet.cpp
index 56b43d5..016d67c 100644
--- a/src/uscxml/debug/DebuggerServlet.cpp
+++ b/src/uscxml/debug/DebuggerServlet.cpp
@@ -238,23 +238,6 @@ void DebuggerServlet::processListSessions(const HTTPServer::Request& request) {
returnData(request, replyData);
}
-std::shared_ptr<LoggerImpl> DebuggerServlet::create() {
- assert(false);
- return std::shared_ptr<LoggerImpl>(this);
-}
-
-void DebuggerServlet::log(LogSeverity severity, const Event& event) {
- pushData(std::shared_ptr<DebugSession>(), event.data);
-}
-
-void DebuggerServlet::log(LogSeverity severity, const Data& data) {
- pushData(std::shared_ptr<DebugSession>(), data);
-}
-
-void DebuggerServlet::log(LogSeverity severity, const std::string& message) {
- pushData(std::shared_ptr<DebugSession>(), Data(message));
-}
-
/*
void DebuggerServlet::handle(const el::LogDispatchData* data) {
}
diff --git a/src/uscxml/debug/DebuggerServlet.h b/src/uscxml/debug/DebuggerServlet.h
index 8d487b2..3b117bf 100644
--- a/src/uscxml/debug/DebuggerServlet.h
+++ b/src/uscxml/debug/DebuggerServlet.h
@@ -21,7 +21,6 @@
#define DEBUGGERSERVLET_H_ATUMDA3G
#include "uscxml/Common.h"
-#include "uscxml/interpreter/LoggingImpl.h"
#include "uscxml/util/BlockingQueue.h"
#include "uscxml/server/HTTPServer.h"
@@ -29,7 +28,7 @@
namespace uscxml {
-class USCXML_API DebuggerServlet : public Debugger, public HTTPServlet, public LoggerImpl {
+class USCXML_API DebuggerServlet : public Debugger, public HTTPServlet {
public:
virtual ~DebuggerServlet() {}
@@ -66,12 +65,6 @@ public:
// void processRemoveBreakPoint(const HTTPServer::Request& request);
// void processPoll(const HTTPServer::Request& request);
- // Logger
- virtual std::shared_ptr<LoggerImpl> create();
-
- 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);
protected:
void serverPushData(std::shared_ptr<DebugSession>);