summaryrefslogtreecommitdiff
path: root/lib/chef/run_context/cookbook_compiler.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/run_context/cookbook_compiler.rb')
-rw-r--r--lib/chef/run_context/cookbook_compiler.rb27
1 files changed, 18 insertions, 9 deletions
diff --git a/lib/chef/run_context/cookbook_compiler.rb b/lib/chef/run_context/cookbook_compiler.rb
index f2598a4f27..25d32ea7e2 100644
--- a/lib/chef/run_context/cookbook_compiler.rb
+++ b/lib/chef/run_context/cookbook_compiler.rb
@@ -31,12 +31,14 @@ class Chef
class CookbookCompiler
attr_reader :events
attr_reader :run_list_expansion
+ attr_reader :logger
def initialize(run_context, run_list_expansion, events)
@run_context = run_context
@events = events
@run_list_expansion = run_list_expansion
@cookbook_order = nil
+ @logger = run_context.logger.with_child(subsystem: "cookbook_compiler")
end
# Chef::Node object for the current run.
@@ -89,7 +91,7 @@ class Chef
cookbook = Chef::Recipe.parse_recipe_name(recipe).first
add_cookbook_with_deps(ordered_cookbooks, seen_cookbooks, cookbook)
end
- Chef::Log.debug("Cookbooks to compile: #{ordered_cookbooks.inspect}")
+ logger.debug("Cookbooks to compile: #{ordered_cookbooks.inspect}")
ordered_cookbooks
end
end
@@ -116,6 +118,7 @@ class Chef
# Doing a full ohai system check is costly, so only do so if we've loaded additional plugins
if ohai_plugin_count > 0
+ # FIXME(log): figure out what the ohai logger looks like here
ohai = Ohai::System.new.run_additional_plugins(Chef::Config[:ohai_segment_plugin_path])
node.consume_ohai_data(ohai)
end
@@ -192,7 +195,7 @@ class Chef
default_file = list_of_attr_files.find { |path| File.basename(path) == "default.rb" }
if root_alias
if default_file
- Chef::Log.error("Cookbook #{cookbook_name} contains both attributes.rb and and attributes/default.rb, ignoring attributes/default.rb")
+ logger.error("Cookbook #{cookbook_name} contains both attributes.rb and and attributes/default.rb, ignoring attributes/default.rb")
list_of_attr_files.delete(default_file)
end
# The actual root_alias path decoding is handled in CookbookVersion#attribute_filenames_by_short_filename
@@ -208,7 +211,8 @@ class Chef
end
def load_attribute_file(cookbook_name, filename)
- Chef::Log.debug("Node #{node.name} loading cookbook #{cookbook_name}'s attribute file #{filename}")
+ # FIXME(log): should be trace
+ logger.debug("Node #{node.name} loading cookbook #{cookbook_name}'s attribute file #{filename}")
attr_file_basename = ::File.basename(filename, ".rb")
node.include_attribute("#{cookbook_name}::#{attr_file_basename}")
rescue Exception => e
@@ -220,7 +224,8 @@ class Chef
files_in_cookbook_by_segment(cookbook_name, :libraries).each do |filename|
next unless File.extname(filename) == ".rb"
begin
- Chef::Log.debug("Loading cookbook #{cookbook_name}'s library file: #{filename}")
+ # FIXME(log): should be trace
+ logger.debug("Loading cookbook #{cookbook_name}'s library file: #{filename}")
Kernel.load(filename)
@events.library_file_loaded(filename)
rescue Exception => e
@@ -240,7 +245,8 @@ class Chef
end
def load_lwrp_provider(cookbook_name, filename)
- Chef::Log.debug("Loading cookbook #{cookbook_name}'s providers from #{filename}")
+ # FIXME(log): should be trace
+ logger.debug("Loading cookbook #{cookbook_name}'s providers from #{filename}")
Chef::Provider::LWRPBase.build_from_file(cookbook_name, filename, self)
@events.lwrp_file_loaded(filename)
rescue Exception => e
@@ -249,7 +255,8 @@ class Chef
end
def load_lwrp_resource(cookbook_name, filename)
- Chef::Log.debug("Loading cookbook #{cookbook_name}'s resources from #{filename}")
+ # FIXME(log): should be trace
+ logger.debug("Loading cookbook #{cookbook_name}'s resources from #{filename}")
Chef::Resource::LWRPBase.build_from_file(cookbook_name, filename, self)
@events.lwrp_file_loaded(filename)
rescue Exception => e
@@ -262,7 +269,8 @@ class Chef
files_in_cookbook_by_segment(cookbook_name, :ohai).each do |filename|
next unless File.extname(filename) == ".rb"
- Chef::Log.debug "Loading Ohai plugin: #{filename} from #{cookbook_name}"
+ # FIXME(log): should be trace
+ logger.debug "Loading Ohai plugin: #{filename} from #{cookbook_name}"
target_name = File.join(target, cookbook_name.to_s, File.basename(filename))
FileUtils.mkdir_p(File.dirname(target_name))
@@ -273,11 +281,12 @@ class Chef
def load_resource_definitions_from_cookbook(cookbook_name)
files_in_cookbook_by_segment(cookbook_name, :definitions).each do |filename|
begin
- Chef::Log.debug("Loading cookbook #{cookbook_name}'s definitions from #{filename}")
+ # FIXME(log): should be trace
+ logger.debug("Loading cookbook #{cookbook_name}'s definitions from #{filename}")
resourcelist = Chef::ResourceDefinitionList.new
resourcelist.from_file(filename)
definitions.merge!(resourcelist.defines) do |key, oldval, newval|
- Chef::Log.info("Overriding duplicate definition #{key}, new definition found in #{filename}")
+ logger.info("Overriding duplicate definition #{key}, new definition found in #{filename}")
newval
end
@events.definition_file_loaded(filename)