- From: Christian Fröstl <
>
- To: "
" <
>
- Subject: [chef] Re: Re: Logging and references questions
- Date: Wed, 23 Apr 2014 08:48:34 +0000
- Accept-language: de-DE, en-US
Hi there,
I just loaded the Cookbook from juliandunn to get some output with the
chef_handler. My code looks like the following:
Handler:
require 'chef/log'
module Opscode
class CookbookVersionsHandler < Chef::Handler
def report
cookbooks = run_context.cookbook_collection
Chef::Log.debug("Cookbooks and versions run: #{cookbooks.keys.map {|x|
cookbooks[x].name.to_s + " " + cookbooks[x].version} }")
end
end
End
Recipe:
chef_handler "Opscode::CookbookVersionsHandler" do
source "#{node["chef_handler"]["handler_path"]}/chf.rb"
supports :report => true
action :enable
End
At the end of the client run, the Handler will run, too. But I don’t get
some output:
Running handlers:
- Opscode::CookbookVersionsHandler
Running handlers complete
Chef Client finished, 4/117 resources updated in 20.13747256 seconds
How can I debug the missing Chef::Log message?
Thanks,
Christian
Am 16.04.14 20:25 schrieb "Daniel DeLeo" unter
<
>:
>
>
>
On Wednesday, April 16, 2014 at 4:16 AM, Christian Fröstl wrote:
>
>
> Hi there,
>
>
>
> I have problems with understanding the logging procedure with chef.
>
>
>
> I can log some information by using the following syntax:
>
> log „foo" do
>
> level :debug
>
> end
>
>
>
>
>
> Now I find in some cookbooks the following spelling:
>
> Chef::Log.debug("Node has Chef Server Recipe?
>
>#{node.recipe?("chef-server")}“)
>
>
>
This blog post is a pretty awesome and thorough description of how
>
chef-client has two stages: compile and converge:
>
http://erik.hollensbe.org/2013/03/16/the-chef-resource-run-queue/
>
>
`Chef::Log.debug` is a method call that writes a string to the logger,
>
which then writes it do some device (or not, depending on your log level,
>
etc.). The log resource puts an item in the resource_collection queue. In
>
the converge phase chef iterates over this queue, and will eventually run
>
this code
>
https://github.com/opscode/chef/blob/master/lib/chef/provider/log.rb
>
which you can see is more or less the same as Chef::Log.debug(). So the
>
primary difference is the timing.
>
>
>
>
> What does Chef::Log.debug exactly do?
>
> I do not get any output if i run the chef-client in normal or in debug
>
>mode. What is the STDOUT from Chef::Log?
>
>
Did you configure chef to log to a file? Check your client.rb.
>
>
>
>
> By the way, I am not really sure what Chef:: represents. Where can I
>
>find the class or module Chef?
>
> In some scripts I the other references like Chef::Client::SANE_PATHS.
>
>Where can I find the content of such references?
>
>
>
> Sorry if the questions are a litte bit stupid, but I am right new in
>
>writing Code.
>
One easy way to spelunk the code is to clone the git repo from here:
>
https://github.com/opscode/chef and use `git grep` to search the codebase.
>
>
>
>
>
>
> Thank you very much,
>
>
>
> Christian
>
HTH,
>
>
--
>
Daniel DeLeo
>
>
>
Archive powered by MHonArc 2.6.16.