[chef] Re: Re: Re: Logging and references questions


Chronological Thread 
  • From: "Julian C. Dunn" < >
  • To: " " < >
  • Subject: [chef] Re: Re: Re: Logging and references questions
  • Date: Wed, 23 Apr 2014 09:47:13 -0400

Ohai, this is the author here... :-)

Since it's logging at debug level you'll need -l debug.

Actually, this handler is obsolete if you are on Chef 11.12.x, which
prints the cookbook versions as part of the beginning of the run:

$ sudo chef-client --force-logger
[2014-04-17T12:50:59-04:00] INFO: *** Chef 11.12.2 ***
[2014-04-17T12:50:59-04:00] INFO: Chef-client pid: 10233
[2014-04-17T12:51:01-04:00] INFO: Run List is [role[base-linux], role[fedora]]
[2014-04-17T12:51:01-04:00] INFO: Run List expands to
[selinux::permissive, users::sysadmins, sudo, chef-client::config,
chef-client::service, chef-client::delete_validation, ntp, stdutils,
yum, yum-fedora]
[2014-04-17T12:51:01-04:00] INFO: Starting Chef Run for [deleted]
[2014-04-17T12:51:01-04:00] INFO: Running start handlers
[2014-04-17T12:51:01-04:00] INFO: Start handlers complete.
[2014-04-17T12:51:02-04:00] INFO: Loading cookbooks 
,
,
 
,
 
,
 
,
,
 
,
 
,
 
,



regards,
Julian

On Wed, Apr 23, 2014 at 4:48 AM, Christian Fröstl
< >
 wrote:
> 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
>>
>>
>>
>



-- 
[ Julian C. Dunn 
< >
          * Sorry, I'm    ]
[ WWW: http://www.aquezada.com/staff/julian    * only Web 1.0  ;]
gopher://sdf.org/1/users/keymaker/           * compliant!    ;]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9       ]



Archive powered by MHonArc 2.6.16.

§