diff options
author | Tim Smith <tsmith84@gmail.com> | 2016-04-22 10:11:38 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2016-04-22 10:13:40 -0700 |
commit | 3fd82e1d5b751dd241001821adf437b78fb6d160 (patch) | |
tree | f6b17e7b3746ddfac5e5b312a8013be2a47205a2 | |
parent | dca7249654e11ac428bd481d4881ac8be6592901 (diff) | |
download | ohai-3fd82e1d5b751dd241001821adf437b78fb6d160.tar.gz |
Consistent plugin debug logging
This makes it a lot easier to read things
-rw-r--r-- | lib/ohai/dsl/plugin/versionvii.rb | 2 | ||||
-rw-r--r-- | lib/ohai/mixin/command.rb | 6 | ||||
-rw-r--r-- | lib/ohai/mixin/gce_metadata.rb | 4 | ||||
-rw-r--r-- | lib/ohai/plugins/bsd/virtualization.rb | 22 | ||||
-rw-r--r-- | lib/ohai/plugins/digital_ocean.rb | 4 | ||||
-rw-r--r-- | lib/ohai/plugins/ec2.rb | 18 | ||||
-rw-r--r-- | lib/ohai/plugins/eucalyptus.rb | 8 | ||||
-rw-r--r-- | lib/ohai/plugins/gce.rb | 4 | ||||
-rw-r--r-- | lib/ohai/plugins/ip_scopes.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/linode.rb | 4 | ||||
-rw-r--r-- | lib/ohai/plugins/softlayer.rb | 4 | ||||
-rw-r--r-- | lib/ohai/plugins/virtualization.rb | 2 | ||||
-rw-r--r-- | spec/unit/mixin/command_spec.rb | 10 |
13 files changed, 45 insertions, 45 deletions
diff --git a/lib/ohai/dsl/plugin/versionvii.rb b/lib/ohai/dsl/plugin/versionvii.rb index f129f828..f9c62bd7 100644 --- a/lib/ohai/dsl/plugin/versionvii.rb +++ b/lib/ohai/dsl/plugin/versionvii.rb @@ -89,7 +89,7 @@ module Ohai elsif collector.has_key?(:default) self.instance_eval(&collector[:default]) else - Ohai::Log.debug("No data to collect for plugin #{self.name}. Continuing...") + Ohai::Log.debug("Plugin #{self.name}: No data to collect. Skipping...") end end diff --git a/lib/ohai/mixin/command.rb b/lib/ohai/mixin/command.rb index 6823ccf2..a17d8917 100644 --- a/lib/ohai/mixin/command.rb +++ b/lib/ohai/mixin/command.rb @@ -36,13 +36,13 @@ module Ohai so = Mixlib::ShellOut.new(cmd, options) begin so.run_command - Ohai::Log.debug("Plugin #{self.name} ran '#{cmd}' and returned #{so.exitstatus}") + Ohai::Log.debug("Plugin #{self.name}: ran '#{cmd}' and returned #{so.exitstatus}") so rescue Errno::ENOENT => e - Ohai::Log.debug("Plugin #{self.name} ran '#{cmd}' and failed #{e.inspect}") + Ohai::Log.debug("Plugin #{self.name}: ran '#{cmd}' and failed #{e.inspect}") raise Ohai::Exceptions::Exec, e rescue Mixlib::ShellOut::CommandTimeout => e - Ohai::Log.debug("Plugin #{self.name} ran '#{cmd}' and timed out after #{options[:timeout]} seconds") + Ohai::Log.debug("Plugin #{self.name}: ran '#{cmd}' and timed out after #{options[:timeout]} seconds") raise Ohai::Exceptions::Exec, e end end diff --git a/lib/ohai/mixin/gce_metadata.rb b/lib/ohai/mixin/gce_metadata.rb index 53d4ec10..aef65250 100644 --- a/lib/ohai/mixin/gce_metadata.rb +++ b/lib/ohai/mixin/gce_metadata.rb @@ -30,7 +30,7 @@ module Ohai begin saddr = Socket.pack_sockaddr_in(port, addr) rescue SocketError => e # occurs when non-GCE systems try to resolve metadata.google.internal - Ohai::Log.debug("gce mixin: can_metadata_connect? failed setting up socket: #{e}") + Ohai::Log.debug("Mixin GCE: can_metadata_connect? failed setting up socket: #{e}") return false end @@ -53,7 +53,7 @@ module Ohai end rescue SystemCallError end - Ohai::Log.debug("gce mixin: can_metadata_connect? == #{connected}") + Ohai::Log.debug("Mixin GCE: can_metadata_connect? == #{connected}") connected end diff --git a/lib/ohai/plugins/bsd/virtualization.rb b/lib/ohai/plugins/bsd/virtualization.rb index 40ebeaf6..f6a791ef 100644 --- a/lib/ohai/plugins/bsd/virtualization.rb +++ b/lib/ohai/plugins/bsd/virtualization.rb @@ -35,7 +35,7 @@ Ohai.plugin(:Virtualization) do virtualization[:system] = "jail" virtualization[:role] = "guest" virtualization[:systems][:jail] = "guest" - Ohai::Log.debug("Virtualization plugin: Guest running in FreeBSD jail detected") + Ohai::Log.debug("Plugin Virtualization: Guest running in FreeBSD jail detected") end # run jls to get a list of running jails @@ -46,7 +46,7 @@ Ohai.plugin(:Virtualization) do virtualization[:system] = "jail" virtualization[:role] = "host" virtualization[:systems][:jail] = "host" - Ohai::Log.debug("Virtualization plugin: Host running FreeBSD jails detected") + Ohai::Log.debug("Plugin Virtualization: Host running FreeBSD jails detected") end # detect from modules @@ -57,12 +57,12 @@ Ohai.plugin(:Virtualization) do virtualization[:system] = "vbox" virtualization[:role] = "host" virtualization[:systems][:vbox] = "host" - Ohai::Log.debug("Virtualization plugin: Guest running on VirtualBox detected") + Ohai::Log.debug("Plugin Virtualization: Guest running on VirtualBox detected") when /vboxguest/ virtualization[:system] = "vbox" virtualization[:role] = "guest" virtualization[:systems][:vbox] = "guest" - Ohai::Log.debug("Virtualization plugin: Host running VirtualBox detected") + Ohai::Log.debug("Plugin Virtualization: Host running VirtualBox detected") end end @@ -71,7 +71,7 @@ Ohai.plugin(:Virtualization) do virtualization[:system] = "bhyve" virtualization[:role] = "host" virtualization[:systems][:bhyve] = "host" - Ohai::Log.debug("Virtualization plugin: Host running bhyve detected") + Ohai::Log.debug("Plugin Virtualization: Host running bhyve detected") end # Detect KVM/QEMU paravirt guests from cpu, report as KVM @@ -81,7 +81,7 @@ Ohai.plugin(:Virtualization) do virtualization[:system] = "kvm" virtualization[:role] = "guest" virtualization[:systems][:kvm] = "guest" - Ohai::Log.debug("Virtualization plugin: Guest running on KVM detected") + Ohai::Log.debug("Plugin Virtualization: Guest running on KVM detected") end # gather hypervisor of guests from sysctl kern.vm_guest @@ -93,22 +93,22 @@ Ohai.plugin(:Virtualization) do virtualization[:system] = "vmware" virtualization[:role] = "guest" virtualization[:systems][:vmware] = "guest" - Ohai::Log.debug("Virtualization plugin: Guest running on VMware detected") + Ohai::Log.debug("Plugin Virtualization: Guest running on VMware detected") when /hv/ virtualization[:system] = "hyperv" virtualization[:role] = "guest" virtualization[:systems][:hyperv] = "guest" - Ohai::Log.debug("Virtualization plugin: Guest running on Hyper-V detected") + Ohai::Log.debug("Plugin Virtualization: Guest running on Hyper-V detected") when /xen/ virtualization[:system] = "xen" virtualization[:role] = "guest" virtualization[:systems][:xen] = "guest" - Ohai::Log.debug("Virtualization plugin: Guest running on Xen detected") + Ohai::Log.debug("Plugin Virtualization: Guest running on Xen detected") when /bhyve/ virtualization[:system] = "bhyve" virtualization[:role] = "guest" virtualization[:systems][:bhyve] = "guest" - Ohai::Log.debug("Virtualization plugin: Guest running on bhyve detected") + Ohai::Log.debug("Plugin Virtualization: Guest running on bhyve detected") end # parse dmidecode to discover various virtualization guests @@ -118,7 +118,7 @@ Ohai.plugin(:Virtualization) do virtualization[:system] = guest virtualization[:role] = "guest" virtualization[:systems][guest.to_sym] = "guest" - Ohai::Log.debug("Virtualization plugin: Guest running on #{guest} detected") + Ohai::Log.debug("Plugin Virtualization: Guest running on #{guest} detected") end end end diff --git a/lib/ohai/plugins/digital_ocean.rb b/lib/ohai/plugins/digital_ocean.rb index 3b422df0..a06c3c67 100644 --- a/lib/ohai/plugins/digital_ocean.rb +++ b/lib/ohai/plugins/digital_ocean.rb @@ -63,7 +63,7 @@ Ohai.plugin(:DigitalOcean) do collect_data do if looks_like_digital_ocean? - Ohai::Log.debug("digitalocean plugin: looks_like_digital_ocean? == true") + Ohai::Log.debug("Plugin Digitalocean: looks_like_digital_ocean? == true") digital_ocean Mash.new hint = hint?("digital_ocean") || {} hint.each { |k, v| digital_ocean[k] = v unless k == "ip_addresses" } @@ -74,7 +74,7 @@ Ohai.plugin(:DigitalOcean) do # https://developers.digitalocean.com/#droplets digital_ocean[:networks] = extract_droplet_ip_addresses else - Ohai::Log.debug("digitalocean plugin: No hints present for and doesn't look like digitalocean") + Ohai::Log.debug("Plugin Digitalocean: No hints present for and doesn't look like digitalocean") false end end diff --git a/lib/ohai/plugins/ec2.rb b/lib/ohai/plugins/ec2.rb index 4623ad2d..0902c781 100644 --- a/lib/ohai/plugins/ec2.rb +++ b/lib/ohai/plugins/ec2.rb @@ -41,13 +41,13 @@ Ohai.plugin(:EC2) do begin # detect a version of '4.2.amazon' if dmi[:bios][:all_records][0][:Version] =~ /amazon/ - Ohai::Log.debug("ec2 plugin: has_ec2_dmi? == true") + Ohai::Log.debug("Plugin EC2: has_ec2_dmi? == true") return true end rescue NoMethodError # dmi[:bios][:all_records][0][:Version] may not exist end - Ohai::Log.debug("ec2 plugin: has_ec2_dmi? == false") + Ohai::Log.debug("Plugin EC2: has_ec2_dmi? == false") return false end @@ -56,11 +56,11 @@ Ohai.plugin(:EC2) do def has_ec2_xen_uuid? if ::File.exist?("/sys/hypervisor/uuid") if ::File.read("/sys/hypervisor/uuid") =~ /^ec2/ - Ohai::Log.debug("ec2 plugin: has_ec2_xen_uuid? == true") + Ohai::Log.debug("Plugin EC2: has_ec2_xen_uuid? == true") return true end end - Ohai::Log.debug("ec2 plugin: has_ec2_xen_uuid? == false") + Ohai::Log.debug("Plugin EC2: has_ec2_xen_uuid? == false") return false end @@ -70,13 +70,13 @@ Ohai.plugin(:EC2) do begin # detect an Organization of 'Amazon.com' if kernel[:os_info][:organization] =~ /Amazon/ - Ohai::Log.debug("ec2 plugin: has_amazon_org? == true") + Ohai::Log.debug("Plugin EC2: has_amazon_org? == true") return true end rescue NoMethodError # kernel[:os_info][:organization] may not exist end - Ohai::Log.debug("ec2 plugin: has_amazon_org? == false") + Ohai::Log.debug("Plugin EC2: has_amazon_org? == false") return false end @@ -91,7 +91,7 @@ Ohai.plugin(:EC2) do collect_data do if looks_like_ec2? - Ohai::Log.debug("ec2 plugin: looks_like_ec2? == true") + Ohai::Log.debug("Plugin EC2: looks_like_ec2? == true") ec2 Mash.new fetch_metadata.each do |k, v| # fetch_metadata returns IAM security credentials, including the IAM user's @@ -104,11 +104,11 @@ Ohai.plugin(:EC2) do ec2[:userdata] = fetch_userdata # ASCII-8BIT is equivalent to BINARY in this case if ec2[:userdata] && ec2[:userdata].encoding.to_s == "ASCII-8BIT" - Ohai::Log.debug("ec2 plugin: Binary UserData Found. Storing in base64") + Ohai::Log.debug("Plugin EC2: Binary UserData Found. Storing in base64") ec2[:userdata] = Base64.encode64(ec2[:userdata]) end else - Ohai::Log.debug("ec2 plugin: looks_like_ec2? == false") + Ohai::Log.debug("Plugin EC2: looks_like_ec2? == false") false end end diff --git a/lib/ohai/plugins/eucalyptus.rb b/lib/ohai/plugins/eucalyptus.rb index 6fd427c5..d9febfcb 100644 --- a/lib/ohai/plugins/eucalyptus.rb +++ b/lib/ohai/plugins/eucalyptus.rb @@ -41,12 +41,12 @@ Ohai.plugin(:Eucalyptus) do network[:interfaces].values.each do |iface| mac = get_mac_address(iface[:addresses]) if mac =~ /^[dD]0:0[dD]:/ - Ohai::Log.debug("eucalyptus plugin: has_euca_mac? == true (#{mac})") + Ohai::Log.debug("Plugin Eucalyptus: has_euca_mac? == true (#{mac})") return true end end - Ohai::Log.debug("eucalyptus plugin: has_euca_mac? == false") + Ohai::Log.debug("Plugin Eucalyptus: has_euca_mac? == false") false end @@ -58,7 +58,7 @@ Ohai.plugin(:Eucalyptus) do collect_data do if looks_like_euca? - Ohai::Log.debug("eucalyptus plugin: looks_like_euca? == true") + Ohai::Log.debug("Plugin Eucalyptus: looks_like_euca? == true") eucalyptus Mash.new self.fetch_metadata.each do |k, v| # Eucalyptus 3.4+ supports IAM roles and Instance Profiles much like AWS @@ -73,7 +73,7 @@ Ohai.plugin(:Eucalyptus) do end eucalyptus[:userdata] = self.fetch_userdata else - Ohai::Log.debug("eucalyptus plugin: looks_like_euca? == false") + Ohai::Log.debug("Plugin Eucalyptus: looks_like_euca? == false") false end end diff --git a/lib/ohai/plugins/gce.rb b/lib/ohai/plugins/gce.rb index 275a9770..e913070c 100644 --- a/lib/ohai/plugins/gce.rb +++ b/lib/ohai/plugins/gce.rb @@ -41,11 +41,11 @@ Ohai.plugin(:GCE) do collect_data do if looks_like_gce? - Ohai::Log.debug("gce plugin: looks_like_gce? == true") + Ohai::Log.debug("Plugin GCE: looks_like_gce? == true") gce Mash.new fetch_metadata.each { |k, v| gce[k] = v } else - Ohai::Log.debug("gce plugin: looks_like_gce? == false") + Ohai::Log.debug("Plugin GCE: looks_like_gce? == false") false end end diff --git a/lib/ohai/plugins/ip_scopes.rb b/lib/ohai/plugins/ip_scopes.rb index 0785fbc6..1eb2dea1 100644 --- a/lib/ohai/plugins/ip_scopes.rb +++ b/lib/ohai/plugins/ip_scopes.rb @@ -43,7 +43,7 @@ Ohai.plugin(:IpScopes) do rescue LoadError => e # our favourite gem is not installed. Boohoo. - Ohai::Log.debug("ip_scopes: cannot load gem, plugin disabled: #{e}") + Ohai::Log.debug("Plugin ip_scopes: cannot load gem, plugin disabled: #{e}") end end diff --git a/lib/ohai/plugins/linode.rb b/lib/ohai/plugins/linode.rb index 1d122cd9..c096f228 100644 --- a/lib/ohai/plugins/linode.rb +++ b/lib/ohai/plugins/linode.rb @@ -53,13 +53,13 @@ Ohai.plugin(:Linode) do collect_data do # Setup linode mash if it is a linode system if looks_like_linode? - Ohai::Log.debug("linode plugin: looks_like_linode? == true") + Ohai::Log.debug("Plugin Linode: looks_like_linode? == true") linode Mash.new get_ip_address(:public_ip, :eth0) get_ip_address(:private_ip, "eth0:1") hint?("linode").each { |k, v| linode[k] = v } if hint?("linode").kind_of?(Hash) else - Ohai::Log.debug("linode plugin: looks_like_linode? == false") + Ohai::Log.debug("Plugin Linode: looks_like_linode? == false") end end end diff --git a/lib/ohai/plugins/softlayer.rb b/lib/ohai/plugins/softlayer.rb index 528d0785..2165a822 100644 --- a/lib/ohai/plugins/softlayer.rb +++ b/lib/ohai/plugins/softlayer.rb @@ -37,12 +37,12 @@ Ohai.plugin(:Softlayer) do collect_data do # Adds softlayer Mash if looks_like_softlayer? - Ohai::Log.debug("softlayer plugin: looks_like_softlayer? == true") + Ohai::Log.debug("Plugin Softlayer: looks_like_softlayer? == true") metadata = fetch_metadata softlayer Mash.new metadata.each { |k, v| softlayer[k] = v } if metadata else - Ohai::Log.debug("softlayer plugin: looks_like_softlayer? == false") + Ohai::Log.debug("Plugin Softlayer: looks_like_softlayer? == false") end end end diff --git a/lib/ohai/plugins/virtualization.rb b/lib/ohai/plugins/virtualization.rb index b3062cc4..7e199b93 100644 --- a/lib/ohai/plugins/virtualization.rb +++ b/lib/ohai/plugins/virtualization.rb @@ -76,7 +76,7 @@ Ohai.plugin(:VirtualizationInfo) do virtconn.close rescue LoadError => e - Ohai::Log.debug("Can't load gem: #{e}. VirtualizationInfo plugin cannot continue.") + Ohai::Log.debug("Plugin Virtualization: Can't load gem: #{e}. Cannot continue.") end end end diff --git a/spec/unit/mixin/command_spec.rb b/spec/unit/mixin/command_spec.rb index 14a91405..fb4ce87f 100644 --- a/spec/unit/mixin/command_spec.rb +++ b/spec/unit/mixin/command_spec.rb @@ -113,7 +113,7 @@ describe Ohai::Mixin::Command, "shell_out" do and_return(256) expect(Ohai::Log).to receive(:debug). - with("Plugin OSSparkleDream ran 'sparkle-dream --version' and returned 256") + with("Plugin OSSparkleDream: ran 'sparkle-dream --version' and returned 256") Ohai::Mixin::Command.shell_out(cmd) end @@ -132,7 +132,7 @@ describe Ohai::Mixin::Command, "shell_out" do expect(Ohai::Log). to receive(:debug). - with("Plugin OSSparkleDream ran 'sparkle-dream --version' and failed " \ + with("Plugin OSSparkleDream: ran 'sparkle-dream --version' and failed " \ "#<Errno::ENOENT: No such file or directory - sparkle-dream>") expect { Ohai::Mixin::Command.shell_out(cmd) }. @@ -153,7 +153,7 @@ describe Ohai::Mixin::Command, "shell_out" do expect(Ohai::Log). to receive(:debug). - with("Plugin OSSparkleDream ran 'sparkle-dream --version' and timed " \ + with("Plugin OSSparkleDream: ran 'sparkle-dream --version' and timed " \ "out after 30 seconds") expect { Ohai::Mixin::Command.shell_out(cmd) }. @@ -178,7 +178,7 @@ describe Ohai::Mixin::Command, "shell_out" do and_return(256) expect(Ohai::Log).to receive(:debug). - with("Plugin OSSparkleDream ran 'sparkle-dream --version' and returned 256") + with("Plugin OSSparkleDream: ran 'sparkle-dream --version' and returned 256") Ohai::Mixin::Command.shell_out(cmd, options) end @@ -196,7 +196,7 @@ describe Ohai::Mixin::Command, "shell_out" do expect(Ohai::Log). to receive(:debug). - with("Plugin OSSparkleDream ran 'sparkle-dream --version' and timed " \ + with("Plugin OSSparkleDream: ran 'sparkle-dream --version' and timed " \ "out after 10 seconds") expect { Ohai::Mixin::Command.shell_out(cmd, options) }. |