diff options
author | Tim Smith <tsmith@chef.io> | 2017-06-01 14:47:18 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2017-06-01 14:47:18 -0700 |
commit | 4642ab0bbf7b4a7d80fc6a937f59f72eec2516f5 (patch) | |
tree | 77736532fca0ddb3050a4acf4e28eadb793132ca | |
parent | 484d8b538d547096ed4472ca5a795d21d0d902db (diff) | |
download | ohai-4642ab0bbf7b4a7d80fc6a937f59f72eec2516f5.tar.gz |
More consistent debug messaging
I think this is the last of it.
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/ohai/mixin/ec2_metadata.rb | 20 | ||||
-rw-r--r-- | lib/ohai/mixin/softlayer_metadata.rb | 4 | ||||
-rw-r--r-- | lib/ohai/plugins/darwin/hardware.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/elixir.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/erlang.rb | 4 | ||||
-rw-r--r-- | lib/ohai/plugins/go.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/hostname.rb | 3 | ||||
-rw-r--r-- | lib/ohai/plugins/java.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/linux/lsb.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/mono.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/nodejs.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/perl.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/php.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/powershell.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/python.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/rackspace.rb | 8 | ||||
-rw-r--r-- | lib/ohai/plugins/rust.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/solaris2/dmi.rb | 6 | ||||
-rw-r--r-- | lib/ohai/plugins/solaris2/network.rb | 4 | ||||
-rw-r--r-- | lib/ohai/plugins/ssh_host_key.rb | 2 | ||||
-rw-r--r-- | spec/unit/plugins/rackspace_spec.rb | 6 |
21 files changed, 40 insertions, 41 deletions
diff --git a/lib/ohai/mixin/ec2_metadata.rb b/lib/ohai/mixin/ec2_metadata.rb index 886191fe..cc755190 100644 --- a/lib/ohai/mixin/ec2_metadata.rb +++ b/lib/ohai/mixin/ec2_metadata.rb @@ -49,24 +49,24 @@ module Ohai def best_api_version @api_version ||= begin - Ohai::Log.debug("ec2 metadata mixin: Fetching http://#{EC2_METADATA_ADDR}/ to determine the latest supported metadata release") + Ohai::Log.debug("Mixin EC2: Fetching http://#{EC2_METADATA_ADDR}/ to determine the latest supported metadata release") response = http_client.get("/") if response.code == "404" - Ohai::Log.debug("ec2 metadata mixin: Received HTTP 404 from metadata server while determining API version, assuming 'latest'") + Ohai::Log.debug("Mixin EC2: Received HTTP 404 from metadata server while determining API version, assuming 'latest'") return "latest" elsif response.code != "200" - raise "Unable to determine EC2 metadata version (returned #{response.code} response)" + raise "Mixin EC2: Unable to determine EC2 metadata version (returned #{response.code} response)" end # Note: Sorting the list of versions may have unintended consequences in # non-EC2 environments. It appears to be safe in EC2 as of 2013-04-12. versions = response.body.split("\n").sort until versions.empty? || EC2_SUPPORTED_VERSIONS.include?(versions.last) pv = versions.pop - Ohai::Log.debug("ec2 metadata mixin: EC2 lists metadata version: #{pv} not yet supported by Ohai") unless pv == "latest" + Ohai::Log.debug("Mixin EC2: EC2 lists metadata version: #{pv} not yet supported by Ohai") unless pv == "latest" end - Ohai::Log.debug("ec2 metadata mixin: Latest supported EC2 metadata version: #{versions.last}") + Ohai::Log.debug("Mixin EC2: Latest supported EC2 metadata version: #{versions.last}") if versions.empty? - raise "Unable to determine EC2 metadata version (no supported entries found)" + raise "Mixin EC2: Unable to determine EC2 metadata version (no supported entries found)" end versions.last end @@ -88,16 +88,16 @@ module Ohai # `nil` and continue the run instead of failing it. def metadata_get(id, api_version) path = "/#{api_version}/meta-data/#{id}" - Ohai::Log.debug("ec2 metadata mixin: Fetching http://#{EC2_METADATA_ADDR}#{path}") + Ohai::Log.debug("Mixin EC2: Fetching http://#{EC2_METADATA_ADDR}#{path}") response = http_client.get(path) case response.code when "200" response.body when "404" - Ohai::Log.debug("ec2 metadata mixin: Encountered 404 response retreiving EC2 metadata path: #{path} ; continuing.") + Ohai::Log.debug("Mixin EC2: Encountered 404 response retreiving EC2 metadata path: #{path} ; continuing.") nil else - raise "Encountered error retrieving EC2 metadata (#{path} returned #{response.code} response)" + raise "Mixin EC2: Encountered error retrieving EC2 metadata (#{path} returned #{response.code} response)" end end @@ -169,7 +169,7 @@ module Ohai end def fetch_userdata - Ohai::Log.debug("ec2 metadata mixin: Fetching http://#{EC2_METADATA_ADDR}/#{best_api_version}/user-data/") + Ohai::Log.debug("Mixin EC2: Fetching http://#{EC2_METADATA_ADDR}/#{best_api_version}/user-data/") response = http_client.get("/#{best_api_version}/user-data/") response.code == "200" ? response.body : nil end diff --git a/lib/ohai/mixin/softlayer_metadata.rb b/lib/ohai/mixin/softlayer_metadata.rb index f8568110..1158e6ca 100644 --- a/lib/ohai/mixin/softlayer_metadata.rb +++ b/lib/ohai/mixin/softlayer_metadata.rb @@ -54,11 +54,11 @@ module ::Ohai::Mixin::SoftlayerMetadata if res.code.to_i.between?(200, 299) res.body else - ::Ohai::Log.error("Unable to fetch item #{full_url}: status (#{res.code}) body (#{res.body})") + ::Ohai::Log.error("Mixin Softlayer: Unable to fetch item #{full_url}: status (#{res.code}) body (#{res.body})") nil end rescue => e - ::Ohai::Log.error("Unable to fetch softlayer metadata from #{u}: #{e.class}: #{e.message}") + ::Ohai::Log.error("Mixin Softlayer: Unable to fetch softlayer metadata from #{u}: #{e.class}: #{e.message}") raise e end end diff --git a/lib/ohai/plugins/darwin/hardware.rb b/lib/ohai/plugins/darwin/hardware.rb index 1aab3b92..5497f36a 100644 --- a/lib/ohai/plugins/darwin/hardware.rb +++ b/lib/ohai/plugins/darwin/hardware.rb @@ -30,7 +30,7 @@ Ohai.plugin(:Hardware) do unless hardware hardware Mash.new else - Ohai::Log.debug("Plugin Darwin Hardware: namespace already exists") + Ohai::Log.debug("Plugin Hardware: namespace already exists") next end diff --git a/lib/ohai/plugins/elixir.rb b/lib/ohai/plugins/elixir.rb index 0dc6b1c3..8b4b9a5e 100644 --- a/lib/ohai/plugins/elixir.rb +++ b/lib/ohai/plugins/elixir.rb @@ -30,7 +30,7 @@ Ohai.plugin(:Elixir) do languages[:elixir] = elixir end rescue Ohai::Exceptions::Exec - Ohai::Log.debug('Elixir plugin: Could not shell_out "elixir -v". Skipping plugin') + Ohai::Log.debug('Plugin Elixir: Could not shell_out "elixir -v". Skipping plugin') end end end diff --git a/lib/ohai/plugins/erlang.rb b/lib/ohai/plugins/erlang.rb index 5097b742..e329b8c1 100644 --- a/lib/ohai/plugins/erlang.rb +++ b/lib/ohai/plugins/erlang.rb @@ -34,7 +34,7 @@ Ohai.plugin(:Erlang) do erlang[:nif_version] = output[2] end rescue Ohai::Exceptions::Exec - Ohai::Log.debug('Erlang plugin: Could not shell_out "erl -eval \'erlang:display(erlang:system_info(otp_release)), erlang:display(erlang:system_info(version)), erlang:display(erlang:system_info(nif_version)), halt().\' -noshell". Skipping data') + Ohai::Log.debug('Plugin Erlang: Could not shell_out "erl -eval \'erlang:display(erlang:system_info(otp_release)), erlang:display(erlang:system_info(version)), erlang:display(erlang:system_info(nif_version)), halt().\' -noshell". Skipping data') end begin @@ -51,7 +51,7 @@ Ohai.plugin(:Erlang) do end end rescue Ohai::Exceptions::Exec - Ohai::Log.debug('Erlang plugin: Could not shell_out "erl +V". Skipping data') + Ohai::Log.debug('Plugin Erlang: Could not shell_out "erl +V". Skipping data') end languages[:erlang] = erlang unless erlang.empty? diff --git a/lib/ohai/plugins/go.rb b/lib/ohai/plugins/go.rb index 3748531b..4eb66132 100644 --- a/lib/ohai/plugins/go.rb +++ b/lib/ohai/plugins/go.rb @@ -28,7 +28,7 @@ Ohai.plugin(:Go) do languages[:go] = go end rescue Ohai::Exceptions::Exec - Ohai::Log.debug('Go plugin: Could not shell_out "go version". Skipping plugin') + Ohai::Log.debug('Plugin Go: Could not shell_out "go version". Skipping plugin') end end end diff --git a/lib/ohai/plugins/hostname.rb b/lib/ohai/plugins/hostname.rb index 29df8813..a6ba86c4 100644 --- a/lib/ohai/plugins/hostname.rb +++ b/lib/ohai/plugins/hostname.rb @@ -149,8 +149,7 @@ Ohai.plugin(:Hostname) do fqdn ourfqdn end rescue - Ohai::Log.debug( - "Plugin Hostname: hostname --fqdn returned an error, probably no domain set") + Ohai::Log.debug("Plugin Hostname: hostname --fqdn returned an error, probably no domain set") end domain collect_domain end diff --git a/lib/ohai/plugins/java.rb b/lib/ohai/plugins/java.rb index b0d482b7..c023bfc3 100644 --- a/lib/ohai/plugins/java.rb +++ b/lib/ohai/plugins/java.rb @@ -43,7 +43,7 @@ Ohai.plugin(:Java) do languages[:java] = java unless java.empty? end rescue Ohai::Exceptions::Exec - Ohai::Log.debug('Java plugin: Could not shell_out "java -mx64m -version". Skipping plugin') + Ohai::Log.debug('Plugin Java: Could not shell_out "java -mx64m -version". Skipping plugin') end end diff --git a/lib/ohai/plugins/linux/lsb.rb b/lib/ohai/plugins/linux/lsb.rb index f5ba064f..018ef1ec 100644 --- a/lib/ohai/plugins/linux/lsb.rb +++ b/lib/ohai/plugins/linux/lsb.rb @@ -54,7 +54,7 @@ Ohai.plugin(:LSB) do end end else - Ohai::Log.debug("Skipping LSB, cannot find /etc/lsb-release or /usr/bin/lsb_release") + Ohai::Log.debug("Plugin LSB: Skipping LSB, cannot find /etc/lsb-release or /usr/bin/lsb_release") end end end diff --git a/lib/ohai/plugins/mono.rb b/lib/ohai/plugins/mono.rb index a7c53935..7ff0798f 100644 --- a/lib/ohai/plugins/mono.rb +++ b/lib/ohai/plugins/mono.rb @@ -44,7 +44,7 @@ Ohai.plugin(:Mono) do languages[:mono] = mono unless mono.empty? end rescue Ohai::Exceptions::Exec - Ohai::Log.debug('Mono plugin: Could not shell_out "mono -V". Skipping plugin') + Ohai::Log.debug('Plugin Mono: Could not shell_out "mono -V". Skipping plugin') end end end diff --git a/lib/ohai/plugins/nodejs.rb b/lib/ohai/plugins/nodejs.rb index c1bb0848..49573bfb 100644 --- a/lib/ohai/plugins/nodejs.rb +++ b/lib/ohai/plugins/nodejs.rb @@ -34,7 +34,7 @@ Ohai.plugin(:Nodejs) do languages[:nodejs] = nodejs if nodejs[:version] end rescue Ohai::Exceptions::Exec - Ohai::Log.debug('Nodejs plugin: Could not shell_out "node -v". Skipping plugin') + Ohai::Log.debug('Plugin Nodejs: Could not shell_out "node -v". Skipping plugin') end end end diff --git a/lib/ohai/plugins/perl.rb b/lib/ohai/plugins/perl.rb index dca682e6..d2655a5a 100644 --- a/lib/ohai/plugins/perl.rb +++ b/lib/ohai/plugins/perl.rb @@ -39,7 +39,7 @@ Ohai.plugin(:Perl) do languages[:perl] = perl unless perl.empty? end rescue Ohai::Exceptions::Exec - Ohai::Log.debug('Perl plugin: Could not shell_out "perl -V:version -V:archname". Skipping plugin') + Ohai::Log.debug('Plugin Perl: Could not shell_out "perl -V:version -V:archname". Skipping plugin') end end end diff --git a/lib/ohai/plugins/php.rb b/lib/ohai/plugins/php.rb index a1f6770c..70af1caa 100644 --- a/lib/ohai/plugins/php.rb +++ b/lib/ohai/plugins/php.rb @@ -46,7 +46,7 @@ Ohai.plugin(:PHP) do languages[:php] = php unless php.empty? end rescue Ohai::Exceptions::Exec - Ohai::Log.debug('Php plugin: Could not shell_out "php -v". Skipping plugin') + Ohai::Log.debug('Plugin Php: Could not shell_out "php -v". Skipping plugin') end end end diff --git a/lib/ohai/plugins/powershell.rb b/lib/ohai/plugins/powershell.rb index af8da75d..b79e8190 100644 --- a/lib/ohai/plugins/powershell.rb +++ b/lib/ohai/plugins/powershell.rb @@ -51,7 +51,7 @@ Ohai.plugin(:Powershell) do languages[:powershell] = powershell unless powershell.empty? end rescue Ohai::Exceptions::Exec - Ohai::Log.debug('Powershell plugin: Could not shell_out "powershell.exe -NoLogo -NonInteractive -NoProfile -command $PSVersionTable". Skipping plugin') + Ohai::Log.debug('Plugin Powershell: Could not shell_out "powershell.exe -NoLogo -NonInteractive -NoProfile -command $PSVersionTable". Skipping plugin') end end diff --git a/lib/ohai/plugins/python.rb b/lib/ohai/plugins/python.rb index 749a5f37..d6053f41 100644 --- a/lib/ohai/plugins/python.rb +++ b/lib/ohai/plugins/python.rb @@ -37,7 +37,7 @@ Ohai.plugin(:Python) do languages[:python] = python unless python.empty? end rescue Ohai::Exceptions::Exec - Ohai::Log.debug('Python plugin: Could not shell_out "python -c "import sys; print (sys.version)"". Skipping plugin') + Ohai::Log.debug('Plugin Python: Could not shell_out "python -c "import sys; print (sys.version)"". Skipping plugin') end end end diff --git a/lib/ohai/plugins/rackspace.rb b/lib/ohai/plugins/rackspace.rb index 3fcbc73c..aa6a511b 100644 --- a/lib/ohai/plugins/rackspace.rb +++ b/lib/ohai/plugins/rackspace.rb @@ -92,7 +92,7 @@ Ohai.plugin(:Rackspace) do end end rescue Ohai::Exceptions::Exec - Ohai::Log.debug("rackspace plugin: Unable to find xenstore-ls, cannot capture region information for Rackspace cloud") + Ohai::Log.debug("Plugin Rackspace: Unable to find xenstore-ls, cannot capture region information for Rackspace cloud") nil end @@ -104,7 +104,7 @@ Ohai.plugin(:Rackspace) do rackspace[:instance_id] = so.stdout.gsub(/instance-/, "") end rescue Ohai::Exceptions::Exec - Ohai::Log.debug("rackspace plugin: Unable to find xenstore-read, cannot capture instance ID information for Rackspace cloud") + Ohai::Log.debug("Plugin Rackspace: Unable to find xenstore-read, cannot capture instance ID information for Rackspace cloud") nil end @@ -119,7 +119,7 @@ Ohai.plugin(:Rackspace) do if so.exitstatus == 0 networks.push(FFI_Yajl::Parser.new.parse(so.stdout)) else - Ohai::Log.debug("rackspace plugin: Unable to capture custom private networking information for Rackspace cloud") + Ohai::Log.debug("Plugin Rackspace: Unable to capture custom private networking information for Rackspace cloud") return false end end @@ -128,7 +128,7 @@ Ohai.plugin(:Rackspace) do networks.delete_if { |hash| hash["label"] == "public" } end rescue Ohai::Exceptions::Exec - Ohai::Log.debug("rackspace plugin: Unable to capture custom private networking information for Rackspace cloud") + Ohai::Log.debug("Plugin Rackspace: Unable to capture custom private networking information for Rackspace cloud") nil end diff --git a/lib/ohai/plugins/rust.rb b/lib/ohai/plugins/rust.rb index 0d6435df..f2aca5fb 100644 --- a/lib/ohai/plugins/rust.rb +++ b/lib/ohai/plugins/rust.rb @@ -28,7 +28,7 @@ Ohai.plugin(:Rust) do languages[:rust] = rust if rust[:version] end rescue Ohai::Exceptions::Exec - Ohai::Log.debug('Rust plugin: Could not shell_out "rustc --version". Skipping plugin') + Ohai::Log.debug('Plugin Rust: Could not shell_out "rustc --version". Skipping plugin') end end end diff --git a/lib/ohai/plugins/solaris2/dmi.rb b/lib/ohai/plugins/solaris2/dmi.rb index 87cf2556..d2aa35a4 100644 --- a/lib/ohai/plugins/solaris2/dmi.rb +++ b/lib/ohai/plugins/solaris2/dmi.rb @@ -25,7 +25,7 @@ Ohai.plugin(:DMI) do # if we already have a "dmi" with keys (presumably from dmidecode), don't try smbios # note that a single key just means dmidecode exited with its version if (dmi.class.to_s == "Mash") && (dmi.keys.length > 1) - Ohai::Log.debug("skipping smbios output, since DMI information has already been provided") + Ohai::Log.debug("Plugin DMI: skipping smbios output, since DMI information has already been provided") return end @@ -118,7 +118,7 @@ Ohai.plugin(:DMI) do # remove/replace any characters that don't fall inside permissible ASCII range, or whitespace line = raw_line.gsub(/[^\x20-\x7E\n\t\r]/, ".") if line != raw_line - Ohai::Log.debug("converted characters from line:\n#{raw_line}") + Ohai::Log.debug("Plugin DMI: converted characters from line:\n#{raw_line}") end if header_information = header_information_line.match(line) @@ -137,7 +137,7 @@ Ohai.plugin(:DMI) do dmi_record[:type] = Ohai::Common::DMI.id_lookup(id) else - Ohai::Log.debug("unrecognized header type; skipping") + Ohai::Log.debug("Plugin DMI: unrecognized header type; skipping") dmi_record = nil next end diff --git a/lib/ohai/plugins/solaris2/network.rb b/lib/ohai/plugins/solaris2/network.rb index 7dac5a55..c13e5ffc 100644 --- a/lib/ohai/plugins/solaris2/network.rb +++ b/lib/ohai/plugins/solaris2/network.rb @@ -180,11 +180,11 @@ Ohai.plugin(:Network) do else matches[:name] end - Ohai::Log.debug("found interface device: #{network[:default_interface]} #{matches[:name]}") + Ohai::Log.debug("Plugin Network: found interface device: #{network[:default_interface]} #{matches[:name]}") end matches = /gateway: (\S+)/.match(line) if matches - Ohai::Log.debug("found gateway: #{matches[1]}") + Ohai::Log.debug("Plugin Network: found gateway: #{matches[1]}") network[:default_gateway] = matches[1] end end diff --git a/lib/ohai/plugins/ssh_host_key.rb b/lib/ohai/plugins/ssh_host_key.rb index 323ddc14..44b9b44c 100644 --- a/lib/ohai/plugins/ssh_host_key.rb +++ b/lib/ohai/plugins/ssh_host_key.rb @@ -44,7 +44,7 @@ Ohai.plugin(:SSHHostKey) do # Darwin "/etc/sshd_config" else - Ohai::Log.debug("Failed to find sshd configuration file") + Ohai::Log.debug("Plugin SSHHostKey: Failed to find sshd configuration file") nil end diff --git a/spec/unit/plugins/rackspace_spec.rb b/spec/unit/plugins/rackspace_spec.rb index eadd0052..68e1a532 100644 --- a/spec/unit/plugins/rackspace_spec.rb +++ b/spec/unit/plugins/rackspace_spec.rb @@ -151,7 +151,7 @@ OUT expect(Ohai::Log). to receive(:debug). - with("rackspace plugin: Unable to find xenstore-ls, cannot capture " \ + with("Plugin Rackspace: Unable to find xenstore-ls, cannot capture " \ "region information for Rackspace cloud") plugin.run @@ -174,7 +174,7 @@ OUT expect(Ohai::Log). to receive(:debug). - with("rackspace plugin: Unable to find xenstore-read, cannot capture " \ + with("Plugin Rackspace: Unable to find xenstore-read, cannot capture " \ "instance ID information for Rackspace cloud") plugin.run @@ -266,7 +266,7 @@ OUT expect(Ohai::Log). to receive(:debug). - with("rackspace plugin: Unable to capture custom private networking " \ + with("Plugin Rackspace: Unable to capture custom private networking " \ "information for Rackspace cloud") plugin.run |