summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2016-02-10 23:48:11 -0800
committermcquin <claire@chef.io>2016-04-01 10:05:42 -0700
commitadf7d64e4151aa00b627907d2b9ab3b3947fcdcf (patch)
tree26d047dee0dc45b81ff453ae3ded132f62915eb3
parent8f48805e75e5e6be27da414d00fb8c7f8bbc9378 (diff)
downloadohai-adf7d64e4151aa00b627907d2b9ab3b3947fcdcf.tar.gz
Improve debug logging when shelling out
Log successful and failed commands. This gives you the necessary context to dig into issues
-rw-r--r--lib/ohai/mixin/command.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/ohai/mixin/command.rb b/lib/ohai/mixin/command.rb
index 6e090db3..0d9ae5a9 100644
--- a/lib/ohai/mixin/command.rb
+++ b/lib/ohai/mixin/command.rb
@@ -30,8 +30,14 @@ module Ohai
module Command
def shell_out(cmd)
m = Mixlib::ShellOut.new(cmd)
- m.run_command
- m
+ begin
+ m.run_command
+ Ohai::Log.debug("Plugin #{self.name} successfully ran command #{cmd}")
+ m
+ rescue Errno::ENOENT => e
+ Ohai::Log.debug("Plugin #{self.name} failed to run command #{cmd}")
+ raise
+ end
end
module_function :shell_out