diff --git a/logstash-core/lib/logstash/config/config_ast.rb b/logstash-core/lib/logstash/config/config_ast.rb index b0b84c1df57..e6b15b5cf40 100644 --- a/logstash-core/lib/logstash/config/config_ast.rb +++ b/logstash-core/lib/logstash/config/config_ast.rb @@ -142,7 +142,8 @@ def compile 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}" } diff --git a/logstash-core/spec/logstash/pipeline_spec.rb b/logstash-core/spec/logstash/pipeline_spec.rb index 7b0ac3356bd..49d042fb760 100644 --- a/logstash-core/spec/logstash/pipeline_spec.rb +++ b/logstash-core/spec/logstash/pipeline_spec.rb @@ -228,6 +228,14 @@ class TestPipeline < LogStash::Pipeline pipeline = TestPipeline.new(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