Sha256: 203b2d5eb23c956a8eac81255ae3092a91bc6ddd8fbea4e8c72acf0bda1b3e70

Contents?: true

Size: 1.39 KB

Versions: 19

Compression:

Stored size: 1.39 KB

Contents

# This function outputs the variable content and its type to the
# debug log. It's similiar to the `notice` function but provides
# a better output format useful to trace variable types and values
# in the manifests.
#
# ```
# $v1 = 'test'
# $v2 = ["1", "2", "3"]
# $v3 = {"a"=>"1", "b"=>"2"}
# $v4 = true
# # $v5 is not defined
# $v6 = { "b" => { "b" => [1,2,3], "c" => true, "d" => { 'x' => 'y' }}, 'x' => 'y', 'z' => [1,2,3,4,5,6]}
# $v7 = 12345
#
# echo($v1, 'My string')
# echo($v2, 'My array')
# echo($v3, 'My hash')
# echo($v4, 'My boolean')
# echo($v5, 'My undef')
# echo($v6, 'My structure')
# echo($v7) # no comment here
# debug log output
# My string (String) "test"
# My array (Array) ["1", "2", "3"]
# My hash (Hash) {"a"=>"1", "b"=>"2"}
# My boolean (TrueClass) true
# My undef (String) ""
# My structure (Hash) {"b"=>{"b"=>["1", "2", "3"], "c"=>true, "d"=>{"x"=>"y"}}, "x"=>"y", "z"=>["1", "2", "3", "4", "5", "6"]}
# (String) "12345"
# ```
Puppet::Functions.create_function(:'extlib::echo') do
  # @param value The value you want to inspect.
  # @param comment An optional comment to prepend to the debug output.
  # @return [Undef] Returns nothing.
  dispatch :echo do
    param 'Any', :value
    optional_param 'String', :comment
  end

  def echo(value, comment = nil)
    message = "(#{value.class}) #{value.inspect}"
    message = "#{comment} #{message}" if comment
    Puppet.debug message
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
puppet-debugger-1.4.0 spec/fixtures/modules/extlib/lib/puppet/functions/extlib/echo.rb
puppet-debugger-1.3.0 spec/fixtures/modules/extlib/lib/puppet/functions/extlib/echo.rb
puppet-debugger-1.2.0 spec/fixtures/modules/extlib/lib/puppet/functions/extlib/echo.rb
puppet-debugger-1.1.0 spec/fixtures/modules/extlib/lib/puppet/functions/extlib/echo.rb
puppet-debugger-1.0.0 spec/fixtures/modules/extlib/lib/puppet/functions/extlib/echo.rb
puppet-debugger-0.19.0 spec/fixtures/modules/extlib/lib/puppet/functions/extlib/echo.rb
puppet-debugger-0.18.0 spec/fixtures/modules/extlib/lib/puppet/functions/extlib/echo.rb
puppet-debugger-0.17.0 spec/fixtures/modules/extlib/lib/puppet/functions/extlib/echo.rb
puppet-debugger-0.16.0 spec/fixtures/modules/extlib/lib/puppet/functions/extlib/echo.rb
puppet-debugger-0.15.2 spec/fixtures/modules/extlib/lib/puppet/functions/extlib/echo.rb
puppet-debugger-0.15.1 spec/fixtures/modules/extlib/lib/puppet/functions/extlib/echo.rb
puppet-debugger-0.15.0 spec/fixtures/modules/extlib/lib/puppet/functions/extlib/echo.rb
puppet-debugger-0.14.0 spec/fixtures/modules/extlib/lib/puppet/functions/extlib/echo.rb
puppet-debugger-0.13.0 spec/fixtures/modules/extlib/lib/puppet/functions/extlib/echo.rb
puppet-debugger-0.12.3 spec/fixtures/modules/extlib/lib/puppet/functions/extlib/echo.rb
puppet-debugger-0.12.2 spec/fixtures/modules/extlib/lib/puppet/functions/extlib/echo.rb
puppet-debugger-0.12.1 spec/fixtures/modules/extlib/lib/puppet/functions/extlib/echo.rb
puppet-debugger-0.12.0 spec/fixtures/modules/extlib/lib/puppet/functions/extlib/echo.rb
puppet-debugger-0.11.0 spec/fixtures/modules/extlib/lib/puppet/functions/extlib/echo.rb