Skip to content

Commit

Permalink
BUG: Fix filter_func logging for config.debug=true
Browse files Browse the repository at this point in the history
Fixes #8456
  • Loading branch information
original-brownbear committed Oct 9, 2017
1 parent 63a05c0 commit 7d07f3d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion logstash-core/lib/logstash/config/config_ast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}" }
Expand Down
8 changes: 8 additions & 0 deletions logstash-core/spec/logstash/pipeline_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7d07f3d

Please sign in to comment.