diff --git a/include/tr/event.h b/include/tr/event.h
index 62c3a96..ce12a51 100644
--- a/include/tr/event.h
+++ b/include/tr/event.h
@@ -42,6 +42,8 @@ TR_CLASSVARS_DECL(TR_Event) {
#define TR_eventSetData(event, data) (((TR_Event)event)->data = (void *)data)
+const char * TR_getEventString(TR_Event);
+
#endif // __TR_EVENT_H__
// vim: set ts=4 sw=4:
diff --git a/include/tr/event_subject.h b/include/tr/event_subject.h
index 2b8e65c..83f2e40 100644
--- a/include/tr/event_subject.h
+++ b/include/tr/event_subject.h
@@ -34,8 +34,9 @@ TR_CLASS(TR_EventSubject) {
};
TR_INSTANCE_INIT(TR_EventSubject);
TR_CLASSVARS_DECL(TR_EventSubject) {
- size_t nevents;
- intptr_t * events;
+ const char ** eventStrings;
+ size_t nevents;
+ intptr_t * events;
};
#include "tr/event.h"
@@ -53,8 +54,8 @@ TR_CLASSVARS_DECL(TR_EventSubject) {
#define TR_eventSubjectHasUnhandledEvents(es) ((es)->emitted > 0)
-intptr_t TR__eventSubjectId(TR_class_ptr, size_t);
-TR_Event TR_eventSubjectEmit(TR_EventSubject, int, void *);
+intptr_t TR__eventSubjectId(TR_class_ptr, size_t);
+TR_Event TR_eventSubjectEmit(TR_EventSubject, int, void *);
#define TR_eventSubjectFinalize(es) ((es)->fin = TRUE)
diff --git a/src/Makefile.am b/src/Makefile.am
index e77d6d2..16e318f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,6 +4,7 @@ AUTOMAKE_OPTIONS = subdir-objects
AM_CFLAGS += -I../include/
TREVENT = event.c \
+ get_event_string.c \
event_dispatcher.c \
event_dispatcher_register_handler.c \
event_dispatcher_set_hearbeat.c \
diff --git a/src/event_dispatcher.c b/src/event_dispatcher.c
index 5987452..c31d0e2 100644
--- a/src/event_dispatcher.c
+++ b/src/event_dispatcher.c
@@ -112,6 +112,13 @@ eventDispatcherCvInit(TR_class_ptr cls)
TR_EVENT_CREATE(cls, TR_DISPATCHER_EVENT_SHUTDOWN);
}
+const char * TR_eventDispatcherStrings[] = {
+ "TR_DISPATCHER_EVENT_HEARTBEAT",
+ "TR_DISPATCHER_EVENT_USER_WAIT",
+ "TR_DISPATCHER_EVENT_DATA_WAIT",
+ "TR_DISPATCHER_EVENT_SHUTDOWN"
+};
+
intptr_t dispatcher_events[TR_DISPATCHER_EVENT_MAX + 1];
TR_INIT_IFACE(TR_Class, eventDispatcherCtor, eventDispatcherDtor, NULL);
TR_CREATE_CLASS(
@@ -120,6 +127,7 @@ TR_CREATE_CLASS(
eventDispatcherCvInit,
TR_IF(TR_Class)) = {
{
+ TR_eventDispatcherStrings,
TR_DISPATCHER_EVENT_MAX + 1,
dispatcher_events
}
diff --git a/src/event_handler_handle_event.c b/src/event_handler_handle_event.c
index 634d656..af58592 100644
--- a/src/event_handler_handle_event.c
+++ b/src/event_handler_handle_event.c
@@ -20,6 +20,8 @@
* along with this program. If not, see .
*/
+#include
+
#include "trbase.h"
#include "trdata.h"
#include "trhash.h"
@@ -35,6 +37,12 @@ TR_eventHandlerHandleEvent(TR_EventHandler this, TR_Event event)
TR_CLASSVARS(TR_EventHandler, TR_GET_CLASS(this))->event_methods,
TR_sdbm((unsigned char *)&event->id, sizeof(event->id)));
+ TR_loggerLog(TR_logger, TR_LOGGER_DEBUG,
+ "HANDLE: %s event on %p with no. %d\n",
+ TR_getEventString(event),
+ event->subject,
+ event->serial);
+
if (! handle_func_hv) {
return 0;
}
diff --git a/src/event_handler_issue_event.c b/src/event_handler_issue_event.c
index 30eef98..0fabb45 100644
--- a/src/event_handler_issue_event.c
+++ b/src/event_handler_issue_event.c
@@ -20,6 +20,8 @@
* along with this program. If not, see .
*/
+#include
+
#include "trbase.h"
#include "tr/event.h"
@@ -28,9 +30,15 @@
void
TR_eventHandlerIssueEvent(TR_EventHandler this, TR_Event event)
{
- int i;
-
if (event) {
+ int i;
+
+ TR_loggerLog(TR_logger, TR_LOGGER_DEBUG,
+ "ISSUE: %s event on %p with no. %d\n",
+ TR_getEventString(event),
+ event->subject,
+ event->serial);
+
for (i=0; indispatcher; i++) {
TR_eventDispatcherEnqueueEvent(this->dispatcher[i], event);
}
diff --git a/src/event_subject.c b/src/event_subject.c
index cc1ad79..7e3d0f8 100644
--- a/src/event_subject.c
+++ b/src/event_subject.c
@@ -32,6 +32,7 @@ static void eventSubjectDtor(void * _this) {}
TR_INIT_IFACE(TR_Class, eventSubjectCtor, eventSubjectDtor, NULL);
TR_CREATE_CLASS(TR_EventSubject, NULL, NULL, TR_IF(TR_Class)) = {
+ NULL,
0,
NULL
};
diff --git a/src/get_event_string.c b/src/get_event_string.c
new file mode 100644
index 0000000..5f3f5a6
--- /dev/null
+++ b/src/get_event_string.c
@@ -0,0 +1,41 @@
+/**
+ * \file
+ *
+ * \author Georg Hopp
+ *
+ * \copyright
+ * Copyright © 2014 Georg Hopp
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include
+
+#include "tr/event.h"
+#include "tr/event_subject.h"
+#include "tr/logger.h"
+#include "trbase.h"
+
+const char *
+TR_getEventString(TR_Event event)
+{
+ TR_class_ptr cls = (TR_class_ptr)(event->id >> 8);
+ size_t idx = event->id & 0xFF;
+
+ idx -= TR_CLASSVARS(TR_EventSubject, cls->parent)->nevents;
+
+ return TR_CLASSVARS(TR_EventSubject, cls)->eventStrings[idx];
+}
+
+// vim: set ts=4 sw=4: