BUG: Fix filter_func logging for config.debug=true

Fixes #8456
This commit is contained in:
Armin 2017-10-09 14:42:11 +02:00 committed by Armin Braun
parent 840439722d
commit 550a6ea554
2 changed files with 10 additions and 1 deletions

View file

@ -78,7 +78,8 @@ module LogStash; module Config; module AST
definitions << "define_singleton_method :#{type}_func do |event|"
definitions << " targeted_outputs = []" if type == "output"
definitions << " events = event" if type == "filter"
definitions << " @logger.debug? && @logger.debug(\"#{type} received\", \"event\" => event.to_hash)"
definitions << " @logger.debug? && @logger.debug(\"#{type} received\", \"event\" => event.to_hash)" if type == "output"
definitions << " @logger.debug? && events.each { |e| @logger.debug(\"#{type} received\", \"event\" => e.to_hash)}" if type == "filter"
sections.select { |s| s.plugin_type.text_value == type }.each do |s|
definitions << s.compile.split("\n", -1).map { |e| " #{e}" }

View file

@ -254,6 +254,14 @@ describe LogStash::Pipeline do
pipeline = mock_pipeline_from_string(test_config_with_filters, pipeline_settings_obj)
pipeline.close
end
it "should log each filtered event if config.debug is set to true" do
pipeline_settings_obj.set("config.debug", true)
pipeline = mock_pipeline_from_string(test_config_with_filters, pipeline_settings_obj)
expect(logger).to receive(:debug).with(/filter received/, anything)
pipeline.filter_func([LogStash::Event.new])
pipeline.close
end
end
context "when there is no command line -w N set" do