write audit log call variant which accepts json objects; old/new value logging for...
[public/netxms.git] / src / server / core / events.cpp
index 55fa2b4..5064cfc 100644 (file)
@@ -57,6 +57,22 @@ EventTemplate::~EventTemplate()
    free(m_description);
 }
 
+/**
+ * Convert event template to JSON
+ */
+json_t *EventTemplate::toJson() const
+{
+   json_t *root = json_object();
+   json_object_set_new(root, "code", json_integer(m_code));
+   char guidText[64];
+   json_object_set_new(root, "guid", json_string(m_guid.toStringA(guidText)));
+   json_object_set_new(root, "severity", json_integer(m_severity));
+   json_object_set_new(root, "flags", json_integer(m_flags));
+   json_object_set_new(root, "message", json_string_t(m_messageTemplate));
+   json_object_set_new(root, "description", json_string_t(m_description));
+   return root;
+}
+
 /**
  * Default constructor for event
  */
@@ -189,7 +205,7 @@ Event::Event(const EventTemplate *eventTemplate, UINT32 sourceId, UINT32 dciId,
                break;
             case 'A':   // InetAddress object
                buffer = (TCHAR *)malloc(64 * sizeof(TCHAR));
-               va_arg(args, InetAddress *)->toString(buffer);
+               (va_arg(args, InetAddress *))->toString(buffer);
                                        m_parameters.add(buffer);
                break;
             case 'h':