diff --git a/probe/src/cgo/kindling.cpp b/probe/src/cgo/kindling.cpp index 86795fb1a..03f374141 100644 --- a/probe/src/cgo/kindling.cpp +++ b/probe/src/cgo/kindling.cpp @@ -7,9 +7,11 @@ #include "sinsp_capture_interrupt_exception.h" #include #include +#include static sinsp *inspector = nullptr; - +sinsp_evt_formatter *formatter = nullptr; +bool printEvent = false; int cnt = 0; map m_events; map m_categories; @@ -61,11 +63,15 @@ void sub_event(char *eventName, char *category) void init_probe() { bool bpf = false; + char* isPrintEvent = getenv("IS_PRINT_EVENT"); + if (isPrintEvent != nullptr && strncmp("true", isPrintEvent, sizeof (isPrintEvent))==0){ + printEvent = true; + } string bpf_probe; inspector = new sinsp(); init_sub_label(); - string output_format; - output_format = "*%evt.num %evt.outputtime %evt.cpu %container.name (%container.id) %proc.name (%thread.tid:%thread.vtid) %evt.dir %evt.type %evt.info"; + string output_format = "*%evt.num %evt.outputtime %evt.cpu %container.name (%container.id) %proc.name (%thread.tid:%thread.vtid) %evt.dir %evt.type %evt.info"; + formatter = new sinsp_evt_formatter(inspector, output_format); try { inspector = new sinsp(); @@ -167,7 +173,12 @@ int getEvent(void **pp_kindling_event) { return -1; } - + if(printEvent){ + string line; + if (formatter->tostring(ev, &line)) { + cout<< line << endl; + } + } kindling_event_t_for_go *p_kindling_event; if(nullptr == *pp_kindling_event) {