summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2005-04-14 03:23:26 +0000
committerLuke Kanies <luke@madstop.com>2005-04-14 03:23:26 +0000
commit4d7bbaa01769094924147d0aaa30dc88bd73e079 (patch)
treecd4250f1707ef4d9743f348fdbe3d7401474aacc /lib
parent0187bf739f6f4d4e649fcb1b25b7c84ec4053cd2 (diff)
downloadpuppet-4d7bbaa01769094924147d0aaa30dc88bd73e079.tar.gz
puppet-4d7bbaa01769094924147d0aaa30dc88bd73e079.tar.xz
puppet-4d7bbaa01769094924147d0aaa30dc88bd73e079.zip
creating extra message methods
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@140 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r--lib/blink.rb20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/blink.rb b/lib/blink.rb
index 70abb2a9c..e132c9cbb 100644
--- a/lib/blink.rb
+++ b/lib/blink.rb
@@ -32,8 +32,20 @@ module Blink
# the hash that determines how our system behaves
@@config = Hash.new(false)
- # produce debugging info
- def Blink.debug(ary)
+
+ msglevels = [:debug,:verbose,:notice,:warning,:error]
+
+ # handle the different message levels
+ msglevels.each { |level|
+ define_method(level,proc { |args|
+ Blink.message(level,args)
+ })
+ module_function level
+ # default to enabling all notice levels except debug
+ @@config[level] = true unless level == :debug
+ }
+
+ def Blink.message(level,ary)
msg = ""
if ary.class == String
msg = ary
@@ -41,9 +53,9 @@ module Blink
msg = ary.join(" ")
end
- if @@config[:debug]
+ if @@config[level]
Blink::Message.new(
- :level => :debug,
+ :level => level,
:source => "Blink",
:message => msg
)