Skip to content

Commit

Permalink
Merge pull request #3398 from kenhys/section-pretty-print
Browse files Browse the repository at this point in the history
Support pretty print Fluent::Config::Section for debugging
  • Loading branch information
ashie committed May 31, 2021
2 parents d3eb28e + 224dc26 commit 6521cca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/fluent/config/section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ def inspect
"<Fluent::Config::Section #{@params.to_json}>"
end

# Used by PP and Pry
def pretty_print(q)
q.text(inspect)
end

def nil?
false
end
Expand Down
9 changes: 9 additions & 0 deletions test/config/test_section.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require_relative '../helper'
require 'fluent/config/section'
require 'pp'

module Fluent::Config
class TestSection < ::Test::Unit::TestCase
Expand Down Expand Up @@ -176,6 +177,14 @@ class TestSection < ::Test::Unit::TestCase
s1 = Fluent::Config::Section.new(h1)
assert_equal(expected, s1.respond_to?(method))
end

test '#pretty_print' do
q = PP.new
h1 = {name: "s1", klass: "A"}
s1 = Fluent::Config::Section.new(h1)
s1.pretty_print(q)
assert_equal s1.inspect, q.output
end
end
end
end
Expand Down

0 comments on commit 6521cca

Please sign in to comment.