+ if( jbuf->offset >= max_size ){
+ EVEL_ERROR("Event exceeded size limit %d", max_size);
+ assert(0);
+ }
+
+ EVEL_EXIT();
+
+ return jbuf->offset;
+}
+/**************************************************************************//**
+ * Encode the event as a JSON event object according to AT&T's schema.
+ *
+ * @param json Pointer to where to store the JSON encoded data.
+ * @param max_size Size of storage available in json_body.
+ * @param event Pointer to the ::EVENT_HEADER to encode.
+ * @returns Number of bytes actually written.
+ *****************************************************************************/
+int evel_json_encode_batch_event(char * json,
+ int max_size,
+ EVENT_HEADER * event)
+{
+ EVEL_JSON_BUFFER json_buffer;
+ EVEL_JSON_BUFFER *jbuf = &json_buffer;
+ EVEL_THROTTLE_SPEC * throttle_spec;
+ int tot_size = 0;
+ EVENT_HEADER * batch_field = NULL;
+ DLIST_ITEM * batch_field_item = NULL;
+
+ EVEL_ENTER();
+
+ /***************************************************************************/
+ /* Get the latest throttle specification for the domain. */
+ /***************************************************************************/
+ throttle_spec = evel_get_throttle_spec(event->event_domain);
+
+ /***************************************************************************/
+ /* Initialize the JSON_BUFFER and open the top-level objects. */
+ /***************************************************************************/
+ if (event->event_domain == EVEL_DOMAIN_BATCH){
+ evel_json_buffer_init(jbuf, json, max_size, throttle_spec);
+
+ if(dlist_count(&event->batch_events) > 0)
+ {
+ evel_json_open_object(jbuf);
+ evel_json_open_named_list(jbuf, "eventList");
+ batch_field_item = dlist_get_first(&event->batch_events);
+ while (batch_field_item != NULL)
+ {
+ batch_field = (EVENT_HEADER *) batch_field_item->item;
+ if(batch_field != NULL){
+ EVEL_DEBUG("Batch Event %p %p added curr fsize %d offset %d depth %d check %d", batch_field_item->item, batch_field, tot_size,jbuf->offset,jbuf->depth,jbuf->checkpoint);
+ evel_json_open_object(jbuf);
+ evel_json_encode_eventtype(jbuf, batch_field);
+ evel_json_close_object(jbuf);
+
+ tot_size += jbuf->offset;
+ EVEL_DEBUG("Batch Event result size %d offset %d depth %d check %d", tot_size,jbuf->offset,jbuf->depth,jbuf->checkpoint);
+ if( tot_size >= max_size ){
+ EVEL_ERROR("Batch Event exceeded size limit %d", tot_size);
+ assert(0);
+ }
+ batch_field_item = dlist_get_next(batch_field_item);
+ }
+ }
+ evel_json_close_list(jbuf);
+ evel_json_close_object(jbuf);
+ }
+
+ }
+ /***************************************************************************/
+ /* Sanity check. */
+ /***************************************************************************/
+ //assert(jbuf->depth == 0);