diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-01-08 00:02:23 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-01-08 00:02:23 +0000 |
commit | cbf10c5e365fb7440c89321a2c329e40424d30b4 (patch) | |
tree | 6be719c4848e73d75d8661f240cd4e1e2f1f2a1d /lib/puppet/log.rb | |
parent | 23f982ecda3fd74867d404b5e784f072db9a1cde (diff) | |
download | puppet-cbf10c5e365fb7440c89321a2c329e40424d30b4.tar.gz puppet-cbf10c5e365fb7440c89321a2c329e40424d30b4.tar.xz puppet-cbf10c5e365fb7440c89321a2c329e40424d30b4.zip |
Merging changes from the head of the rework1 branch, r 784
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@787 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/log.rb')
-rw-r--r-- | lib/puppet/log.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/puppet/log.rb b/lib/puppet/log.rb index 9fff07225..7d4b750c7 100644 --- a/lib/puppet/log.rb +++ b/lib/puppet/log.rb @@ -67,6 +67,12 @@ module Puppet # :nodoc: # Create a new log message. The primary role of this method is to # avoid creating log messages below the loglevel. def Log.create(hash) + unless hash.include?(:level) + raise Puppet::DevError, "Logs require a level" + end + unless @levels.index(hash[:level]) + raise Puppet::DevError, "Invalid log level %s" % hash[:level] + end if @levels.index(hash[:level]) >= @loglevel return Puppet::Log.new(hash) else @@ -159,6 +165,9 @@ module Puppet # :nodoc: # It's worth noting that there's a potential for a loop here, if # the machine somehow gets the destination set as itself. def Log.newmessage(msg) + if @levels.index(msg.level) < @loglevel + return + end @destinations.each { |type, dest| case dest when Module # This is the Syslog module @@ -230,6 +239,10 @@ module Puppet # :nodoc: } end + def Log.sendlevel?(level) + @levels.index(level) >= @loglevel + end + # Reopen all of our logs. def Log.reopen types = @destinations.keys @@ -273,6 +286,10 @@ module Puppet # :nodoc: raise Puppet::DevError, "Level is not a string or symbol: #{args[:level].class}" end + + # Just return unless we're actually at a level we should send + #return unless self.class.sendlevel?(@level) + @message = args[:message].to_s @time = Time.now # this should include the host name, and probly lots of other |