summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-08-03 11:53:58 -0700
committerJames Turnbull <james@lovedthanlost.net>2009-08-04 07:26:59 +1000
commitf6cc59803b32dd1d62cbc5e8ae16ac675ffb296d (patch)
tree4a924f8b18c502188f07284f621ac15c90a4aeed /lib/puppet
parent7c4c00f9e0a8120f6ee273c81cf1aff4379b83c2 (diff)
downloadpuppet-f6cc59803b32dd1d62cbc5e8ae16ac675ffb296d.tar.gz
puppet-f6cc59803b32dd1d62cbc5e8ae16ac675ffb296d.tar.xz
puppet-f6cc59803b32dd1d62cbc5e8ae16ac675ffb296d.zip
Fixes #2483 - Log only copies metadata from RAL objects
We were previously trying to figure out what data was available based on what methods existed, but that caught a different method profile from modules. This fixes it so we only look for this data from Puppet::Type or Puppet::Parameter instances. I had to add the ability to skip data that's not available, since File's 'ensure' parameter doesn't have 'file' data, I assume because of the metaprogramming we do around the 'file' value for 'ensure'. It's a workaround for now, and there's a test in there to verify it, anyway. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/util/log.rb23
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/puppet/util/log.rb b/lib/puppet/util/log.rb
index 6edc7f482..d6d3ba018 100644
--- a/lib/puppet/util/log.rb
+++ b/lib/puppet/util/log.rb
@@ -515,18 +515,10 @@ class Puppet::Util::Log
# We can't just check for whether it responds to :path, because
# plenty of providers respond to that in their normal function.
if (source.is_a?(Puppet::Type) or source.is_a?(Puppet::Parameter)) and source.respond_to?(:path)
- @source = source.path
+ set_source_from_ral(source)
else
@source = source.to_s
end
- if source.respond_to?(:tags)
- source.tags.each { |t| tag(t) }
- end
-
- [:file, :line, :version].each do |param|
- next unless source.respond_to?(param)
- send(param.to_s + "=", source.send(param))
- end
end
def to_report
@@ -536,6 +528,19 @@ class Puppet::Util::Log
def to_s
return @message
end
+
+ private
+
+ def set_source_from_ral(source)
+ @source = source.path
+
+ source.tags.each { |t| tag(t) }
+
+ [:file, :line, :version].each do |param|
+ next unless source.respond_to?(param) and value = source.send(param)
+ send(param.to_s + "=", value)
+ end
+ end
end
# This is for backward compatibility from when we changed the constant to Puppet::Util::Log