There's just something about this message that looks like an error:
debug: Format s not supported for Puppet::FileServing::Metadata; has not implemented method 'from_s'
Not supported! Not implemented! It raises red flags, even though the
message itself is gray.
Generally this message doesn't come up when you're asking for that
specific format, but rather when you're just asking for a list of all
supported formats. The message is particularly spurious in that case.
But, I haven't thought of a way to fix that message, on its own,
without removing data.
So my proposal is to add more context, by reporting which formats *are*
supported. I think that makes the message look more like part of a
discovery process, rather than just a failure.
Here's some example output:
debug: Puppet::FileServing::Metadata does not support format s (has not implemented method 'from_s')
debug: Puppet::FileServing::Metadata supports formats: pson b64_zlib_yaml marshal yaml raw
debug: Using format yaml for Puppet::FileServing::Metadata
It's possible that this is too chatty; I've seen reports on this
mailing list that even the old message alone clogs the debug logs.
So, I'd like to hear some feedback on whether people agree that this is
an improvement.
In addition, do we think it's worthwhile to write unit tests for debug
messages?
Signed-off-by: Jesse Wolfe <
jes...@gmail.com>
---
lib/puppet/network/format.rb | 2 +-
lib/puppet/network/format_handler.rb | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/puppet/network/format.rb b/lib/puppet/network/format.rb
index a5be3af..3d1d98c 100644
--- a/lib/puppet/network/format.rb
+++ b/lib/puppet/network/format.rb
@@ -117,7 +117,7 @@ class Puppet::Network::Format
return true if has_method
- Puppet.debug "Format %s not supported for %s; %s" % [
self.name, klass, message]
+ Puppet.debug "#{klass} does not support format #{
self.name} (#{message})"
return false
end
end
diff --git a/lib/puppet/network/format_handler.rb b/lib/puppet/network/format_handler.rb
index e508a02..13f2401 100644
--- a/lib/puppet/network/format_handler.rb
+++ b/lib/puppet/network/format_handler.rb
@@ -119,6 +119,8 @@ module Puppet::Network::FormatHandler
format_handler.format(b).weight <=> format_handler.format(a).weight
end
+ Puppet.debug "#{self} supports formats: #{result.join(' ')}"
+
put_preferred_format_first(result)
end
@@ -129,8 +131,9 @@ module Puppet::Network::FormatHandler
if list.include?(preferred_format)
list.delete(preferred_format)
list.unshift(preferred_format)
+ Puppet.debug "Using format #{preferred_format} for #{self}"
else
- Puppet.warning "Value of 'preferred_serialization_format' ('#{preferred_format}') is invalid, using default ('#{list.first}')"
+ Puppet.warning "Value of 'preferred_serialization_format' (#{preferred_format}) is invalid for #{self}, using default (#{list.first})"
end
list
end
--
1.6.3.3