Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@
# chefctl -ivd -- --log_level trace
Chef.event_handler do
on :attribute_changed do |precedence, key, value|
# Do absolutely nothing unless debug logging is enabled
next unless Chef::Log.debug?

# Skip attributes coming from ohai
next if precedence == :automatic

Chef::Log.debug('Attributes changed:')

frame = caller.find { |line| line.include?('cookbooks/') }
# Example Entry
# /etc/cinc/local-mode-cache/cache/cookbooks/fb_apt/resources/sources_list.rb:79:in 'block class_from_file'
filename, line_number = frame.split(':')
location = "#{filename}:#{line_number}"
puts(
"attribute_changed: key: #{key}, value: #{value}, precedence: #{precedence} at #{location}",
)
# Trying out improved form
puts(
Chef::Log.debug(
"- node.#{precedence}#{key.map { |n| "[\"#{n}\"]" }.join} = #{value} at #{location}",
)
end
Expand Down
11 changes: 5 additions & 6 deletions cookbooks/boxcutter_ohai/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@

on :run_completed do
if resource_updates.empty?
# Chef::Log.info('NEW: No resources updated.')
puts('No resources updated.')
Chef::Log.debug('No resources updated.')
else
# Chef::Log.info("NEW: Updated #{resource_updates.size} resource(s):")
puts("Updated #{resource_updates.size} resource(s):")
Chef::Log.debug("Updated #{resource_updates.size} resource(s):")
resource_updates.each do |r|
# Chef::Log.info("NEW: - #{r[:name]} (#{r[:cookbook]}::#{r[:recipe]} line #{r[:line]}) via :#{r[:action]}")
puts("- #{r[:name]} (#{r[:cookbook]}::#{r[:recipe]} line #{r[:line]}) via :#{r[:action]}")
Chef::Log.debug(
"- #{r[:name]} (#{r[:cookbook]}::#{r[:recipe]} line #{r[:line]}) via :#{r[:action]}",
)
end
end
end
Expand Down
Loading