@@ -47,16 +47,11 @@ using namespace std;
4747
4848extern bool g_filterchecks_force_raw_times;
4949
50- // todo(jasondellaluce): this list is static and prevents from using
51- // plugin-defined extraction fields. The right way would be to have a filtercheck
52- // list owned by each component and populate depending on the loaded plugins.
53- // this is not something that we plan on supporting for now.
54- static sinsp_filter_check_list s_filterlist;
55-
5650// /////////////////////////////////////////////////////////////////////////////
5751// spy_text_renderer implementation
5852// /////////////////////////////////////////////////////////////////////////////
5953spy_text_renderer::spy_text_renderer (sinsp* inspector,
54+ std::shared_ptr<sinsp_filter_check_list> filter_check_list,
6055 sinsp_cursesui* parent,
6156 int32_t viz_type,
6257 sysdig_output_type sotype,
@@ -65,6 +60,7 @@ spy_text_renderer::spy_text_renderer(sinsp* inspector,
6560{
6661 m_formatter = NULL ;
6762 m_inspector = inspector;
63+ m_filter_check_list = filter_check_list;
6864 m_viz_type = viz_type;
6965 m_linecnt = 0 ;
7066
@@ -79,13 +75,13 @@ spy_text_renderer::spy_text_renderer(sinsp* inspector,
7975 {
8076 m_formatter = new sinsp_evt_formatter (m_inspector,
8177 " *(latency=%evt.latency.human) (fd=%fd.name) %evt.num %evt.time %evt.cpu %container.name (%container.id) %proc.name (%thread.tid:%thread.vtid) %evt.dir %evt.type %evt.info" ,
82- s_filterlist );
78+ *m_filter_check_list );
8379 }
8480 else
8581 {
8682 m_formatter = new sinsp_evt_formatter (m_inspector,
8783 " *(latency=%evt.latency.human) (fd=%fd.name) %evt.num %evt.time %evt.cpu %proc.name %thread.tid %evt.dir %evt.type %evt.info" ,
88- s_filterlist );
84+ *m_filter_check_list );
8985 }
9086 }
9187 else
@@ -94,11 +90,11 @@ spy_text_renderer::spy_text_renderer(sinsp* inspector,
9490 {
9591 m_formatter = new sinsp_evt_formatter (m_inspector,
9692 " *%evt.num %evt.time %evt.cpu %container.name (%container.id) %proc.name (%thread.tid:%thread.vtid) %evt.dir %evt.type %evt.info" ,
97- s_filterlist );
93+ *m_filter_check_list );
9894 }
9995 else
10096 {
101- m_formatter = new sinsp_evt_formatter (m_inspector, DEFAULT_OUTPUT_STR, s_filterlist );
97+ m_formatter = new sinsp_evt_formatter (m_inspector, DEFAULT_OUTPUT_STR, *m_filter_check_list );
10298 }
10399 }
104100 }
@@ -737,7 +733,7 @@ chisel_table_action curses_table_sidemenu::handle_input(int ch)
737733// /////////////////////////////////////////////////////////////////////////////
738734// curses_textbox implementation
739735// /////////////////////////////////////////////////////////////////////////////
740- curses_textbox::curses_textbox (sinsp* inspector, sinsp_cursesui* parent, int32_t viz_type, spy_text_renderer::sysdig_output_type sotype)
736+ curses_textbox::curses_textbox (sinsp* inspector, std::shared_ptr<sinsp_filter_check_list> filter_check_list, sinsp_cursesui* parent, int32_t viz_type, spy_text_renderer::sysdig_output_type sotype)
741737{
742738 ASSERT (inspector != NULL );
743739 ASSERT (parent != NULL );
@@ -748,6 +744,7 @@ curses_textbox::curses_textbox(sinsp* inspector, sinsp_cursesui* parent, int32_t
748744 m_filter = NULL ;
749745 m_text_renderer = NULL ;
750746 m_inspector = inspector;
747+ m_filter_check_list = filter_check_list;
751748 n_prints = 0 ;
752749 m_paused = false ;
753750 m_sidemenu = NULL ;
@@ -766,8 +763,9 @@ curses_textbox::curses_textbox(sinsp* inspector, sinsp_cursesui* parent, int32_t
766763 config.m_scroll_on_append = true ;
767764 config.m_bounding_box = true ;
768765
769- m_text_renderer = new spy_text_renderer (inspector,
770- parent,
766+ m_text_renderer = new spy_text_renderer (inspector,
767+ m_filter_check_list,
768+ parent,
771769 viz_type,
772770 sotype,
773771 m_parent->m_print_containers ,
@@ -854,8 +852,12 @@ curses_textbox::~curses_textbox()
854852
855853void curses_textbox::set_filter (string filter)
856854{
857- sinsp_filter_compiler compiler (m_inspector, filter);
858- m_filter = compiler.compile ();
855+ if (filter != " " )
856+ {
857+ auto filter_factory = std::make_shared<sinsp_filter_factory>(m_inspector, *m_filter_check_list);
858+ sinsp_filter_compiler compiler (filter_factory, filter);
859+ m_filter = compiler.compile ();
860+ }
859861}
860862
861863void curses_textbox::print_no_data ()
0 commit comments