Skip to content

Commit

Permalink
Merge pull request #2751 from fluent/better-log-for-different-secondary
Browse files Browse the repository at this point in the history
output: Show better message for different secondary type
  • Loading branch information
repeatedly authored Jan 7, 2020
2 parents be2d977 + bad3aad commit 4d44ad8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/fluent/plugin/output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def configure(conf)
@secondary.acts_as_secondary(self)
@secondary.configure(secondary_conf)
if (self.class != @secondary.class) && (@custom_format || @secondary.implement?(:custom_format))
log.warn "secondary type should be same with primary one", primary: self.class.to_s, secondary: @secondary.class.to_s
log.warn "Use different plugin for secondary. Check the plugin works with primary like secondary_file", primary: self.class.to_s, secondary: @secondary.class.to_s
end
else
@secondary = nil
Expand Down
6 changes: 3 additions & 3 deletions test/plugin/test_output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ def waiting(seconds)
sub_test_case 'configure secondary' do
test "Warn if primary type is different from secondary type and either primary or secondary has custom_format" do
o = create_output(:buffered)
mock(o.log).warn("secondary type should be same with primary one",
mock(o.log).warn("Use different plugin for secondary. Check the plugin works with primary like secondary_file",
{ primary: o.class.to_s, secondary: "Fluent::Plugin::TestOutput" })

o.configure(config_element('ROOT','',{},[config_element('secondary','',{'@type'=>'test', 'name' => "cool"})]))
Expand All @@ -864,7 +864,7 @@ def waiting(seconds)

test "don't warn if primary type is the same as secondary type" do
o = Fluent::Plugin::TestOutput.new
mock(o.log).warn("secondary type should be same with primary one",
mock(o.log).warn("Use different plugin for secondary. Check the plugin works with primary like secondary_file",
{ primary: o.class.to_s, secondary: "Fluent::Plugin::TestOutput" }).never

o.configure(config_element('ROOT','',{'name' => "cool2"},
Expand All @@ -876,7 +876,7 @@ def waiting(seconds)

test "don't warn if primary type is different from secondary type and both don't have custom_format" do
o = create_output(:standard)
mock(o.log).warn("secondary type should be same with primary one",
mock(o.log).warn("Use different plugin for secondary. Check the plugin works with primary like secondary_file",
{ primary: o.class.to_s, secondary: "Fluent::Plugin::TestOutput" }).never

o.configure(config_element('ROOT','',{},[config_element('secondary','',{'@type'=>'test', 'name' => "cool"})]))
Expand Down
4 changes: 2 additions & 2 deletions test/plugin/test_output_as_buffered_secondary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def dummy_event_stream
i = create_output()
i.configure(config_element('ROOT','',{},[priconf,secconf]))
logs = i.log.out.logs
assert{ logs.any?{|l| l.include?("secondary type should be same with primary one") } }
assert{ logs.any?{|l| l.include?("Use different plugin for secondary. Check the plugin works with primary like secondary_file") } }
end

test 'secondary plugin lifecycle is kicked by primary' do
Expand All @@ -162,7 +162,7 @@ def dummy_event_stream
i = create_output()
i.configure(config_element('ROOT','',{},[priconf,secconf]))
logs = i.log.out.logs
assert{ logs.any?{|l| l.include?("secondary type should be same with primary one") } }
assert{ logs.any?{|l| l.include?("Use different plugin for secondary. Check the plugin works with primary like secondary_file") } }

assert i.secondary.configured?

Expand Down
4 changes: 2 additions & 2 deletions test/test_output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def write(chunk)
end
end

mock(d.instance.log).warn("secondary type should be same with primary one",
mock(d.instance.log).warn("Use different plugin for secondary. Check the plugin works with primary like secondary_file",
{ primary: d.instance.class.to_s, secondary: "Fluent::Plugin::Test2Output" })
d.configure(CONFIG + %[
<secondary>
Expand All @@ -132,7 +132,7 @@ def test_secondary_with_no_warn_log
# ObjectBufferedOutput doesn't implement `custom_filter`
d = Fluent::Test::BufferedOutputTestDriver.new(Fluent::ObjectBufferedOutput)

mock(d.instance.log).warn("secondary type should be same with primary one",
mock(d.instance.log).warn("Use different plugin for secondary. Check the plugin works with primary like secondary_file",
{ primary: d.instance.class.to_s, secondary: "Fluent::Plugin::Test2Output" }).never
d.configure(CONFIG + %[
<secondary>
Expand Down

0 comments on commit 4d44ad8

Please sign in to comment.