diff options
author | Christopher Brown <cb@opscode.com> | 2009-12-14 11:51:00 -0800 |
---|---|---|
committer | Christopher Brown <cb@opscode.com> | 2009-12-14 11:51:00 -0800 |
commit | 227da700bc76ea01ccd8f68076b1d4befd6ead47 (patch) | |
tree | b7d9a70b4714a138d239f4eb431c62b8c9c64f1c /lib | |
parent | 336f3ec002177105233c9d79731d52124266adb8 (diff) | |
download | mixlib-log-227da700bc76ea01ccd8f68076b1d4befd6ead47.tar.gz |
make log level changes backward compatible
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mixlib/log.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/mixlib/log.rb b/lib/mixlib/log.rb index ba6dc92..a506ba2 100644 --- a/lib/mixlib/log.rb +++ b/lib/mixlib/log.rb @@ -63,15 +63,17 @@ module Mixlib # # Throws an ArgumentError if you feed it a bogus log level. def level=(l) - logger.level = @@levels[l] - raise ArgumentError, "Log level must be one of :debug, :info, :warn, :error, or :fatal" if logger.level.nil? + lv = @@levels[l] + raise ArgumentError, "Log level must be one of :debug, :info, :warn, :error, or :fatal" if lv.nil? + logger.level = lv end - def level - @@levels.each do |k,v| - return k if logger.level == v + def level(lv=nil) + if lv.nil? + @@levels.find() {|l| logger.level==l[1]}[0] + else + self.level=(lv) end - nil end # Passes any other method calls on directly to the underlying Logger object created with init. If |