add end of stream notification
[babeltrace.git] / plugins / text / text.c
index 8f72b999eb18fc74ea574c9a6ad0cdf767ff9678..9d72e3a1ed76a0b0765f66f2c33c9c3e1e35f3de 100644 (file)
@@ -72,25 +72,23 @@ const char *loglevel_str [] = {
 };
 
 struct text_options {
-       bool opt_print_all_field_names : 1;
-       bool opt_print_scope_field_names : 1;
-       bool opt_print_header_field_names : 1;
-       bool opt_print_context_field_names : 1;
-       bool opt_print_payload_field_names : 1;
-       bool opt_print_all_fields : 1;
-       bool opt_print_trace_field : 1;
-       bool opt_print_trace_domain_field : 1;
-       bool opt_print_trace_procname_field : 1;
-       bool opt_print_trace_vpid_field : 1;
-       bool opt_print_trace_hostname_field : 1;
-       bool opt_print_trace_default_fields : 1;
-       bool opt_print_loglevel_field : 1;
-       bool opt_print_emf_field : 1;
-       bool opt_print_delta_field : 1;
+       bool print_scope_field_names : 1;
+       bool print_header_field_names : 1;
+       bool print_context_field_names : 1;
+       bool print_payload_field_names : 1;
+       bool print_delta_field : 1;
+       bool print_loglevel_field : 1;
+       bool print_trace_field : 1;
+       bool print_trace_domain_field : 1;
+       bool print_trace_procname_field : 1;
+       bool print_trace_vpid_field : 1;
+       bool print_trace_hostname_field : 1;
+       bool no_size_limit : 1;
 };
 
 struct text_component {
        struct text_options options;
+       FILE *out, *err;
 };
 
 static
@@ -99,15 +97,39 @@ struct text_component *create_text(void)
        return g_new0(struct text_component, 1);
 }
 
-static void destroy_text(void *data)
+static
+void destroy_text_data(struct text_component *data)
 {
        g_free(data);
 }
 
+static void destroy_text(struct bt_component *component)
+{
+       void *data = bt_component_get_private_data(component);
+
+       destroy_text_data(data);
+}
+
 static
 enum bt_component_status handle_notification(struct bt_component *component,
        struct bt_notification *notification)
 {
+       switch (bt_notification_get_type(notification)) {
+       case BT_NOTIFICATION_TYPE_PACKET_START:
+               puts("<packet>");
+               break;
+       case BT_NOTIFICATION_TYPE_PACKET_END:
+               puts("</packet>");
+               break;
+       case BT_NOTIFICATION_TYPE_EVENT:
+               puts("\t<event>");
+               break;
+       case BT_NOTIFICATION_TYPE_STREAM_END:
+               puts("</stream>");
+               break;
+       default:
+               puts("Unhandled notification type");
+       }
        return BT_COMPONENT_STATUS_OK;
 }
 
@@ -135,20 +157,22 @@ enum bt_component_status text_component_init(
        }
 
        ret = bt_component_sink_set_handle_notification_cb(component,
-               handle_notification);
+                       handle_notification);
        if (ret != BT_COMPONENT_STATUS_OK) {
                goto error;
        }
+
+       text->out = stdout;
+       text->err = stderr;
 end:
        return ret;
 error:
-       destroy_text(text);
+       destroy_text_data(text);
        return ret;
 }
 
-
 /* Initialize plug-in entry points. */
-BT_PLUGIN_NAME("ctf-text");
+BT_PLUGIN_NAME("text");
 BT_PLUGIN_DESCRIPTION("Babeltrace text output plug-in.");
 BT_PLUGIN_AUTHOR("Jérémie Galarneau");
 BT_PLUGIN_LICENSE("MIT");
This page took 0.025198 seconds and 4 git commands to generate.