diff options
author | Peter Meier <peter.meier@immerda.ch> | 2009-11-07 12:10:29 +0100 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-11-07 22:16:14 +1100 |
commit | 810980659d86a30cc9dde6018a4749f659fe2d00 (patch) | |
tree | 5acfd02792ec3822a5b7ca3c51194f8cbce9787a /lib/facter.rb | |
parent | b2c1ca56ebc7ec78c71a1fbf6026411494214e67 (diff) | |
download | facter-810980659d86a30cc9dde6018a4749f659fe2d00.tar.gz facter-810980659d86a30cc9dde6018a4749f659fe2d00.tar.xz facter-810980659d86a30cc9dde6018a4749f659fe2d00.zip |
introduce a warn mechanism for debugging
We can now warn messages that will be passed to Kernel.warn if
debugging is enabled.
Diffstat (limited to 'lib/facter.rb')
-rw-r--r-- | lib/facter.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/facter.rb b/lib/facter.rb index 3c69a94..ac06f68 100644 --- a/lib/facter.rb +++ b/lib/facter.rb @@ -68,11 +68,15 @@ module Facter if string.nil? return end - if @@debug != 0 + if self.debugging? puts GREEN + string + RESET end end + def self.debugging? + @@debug != 0 + end + # Return a fact object by name. If you use this, you still have to call # 'value' on it to retrieve the actual value. def self.[](name) @@ -173,6 +177,13 @@ module Facter end end + + def self.warn(msg) + if Facter.debugging? and msg and not msg.empty? + msg.each { |line| Kernel.warn line } + end + end + # Remove them all. def self.reset @collection = nil |