[chef] Logging within a ruby_block


Chronological Thread 
  • From: Mark Selby < >
  • To: " " < >
  • Subject: [chef] Logging within a ruby_block
  • Date: Fri, 6 Mar 2015 12:07:58 -0800

I have searched the interwebs and have not found the answer that I am looking for so hopefully someone where has solved my problem

I want to log stuff using chef log levels when inside a ruby_block. The BELOW DOES NOT WORK

  ruby_block "ruby_block_thing" do
    block do
      foo = my_method
      if foo.sucess?
        Chef::Log.info("sucessfully ran my_method")
        Chef::Log.debug("my_method said #{foo.response}")
      end
    end
    action :run
  end

Any know the "correct" way to log stuff within a ruby block. I am hoping that using puts is not the best answer.

As you can see here I want to output different thing based on different log level.



Archive powered by MHonArc 2.6.16.

§