summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2005-06-29 19:44:25 +0000
committerLuke Kanies <luke@madstop.com>2005-06-29 19:44:25 +0000
commitbb7e2833f0ea9c97d55fcb76e5811c035161256f (patch)
tree560129341856ab4a29d9c3c9a40529627de521e4 /lib/puppet
parentc16ca53ea8d62ffb8e02afddb8ae93cfbae800b2 (diff)
downloadpuppet-bb7e2833f0ea9c97d55fcb76e5811c035161256f.tar.gz
puppet-bb7e2833f0ea9c97d55fcb76e5811c035161256f.tar.xz
puppet-bb7e2833f0ea9c97d55fcb76e5811c035161256f.zip
fixing debugging to severely reduce output but allow it when debugging a specific service
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@319 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/client.rb18
-rw-r--r--lib/puppet/event.rb8
-rw-r--r--lib/puppet/log.rb6
-rw-r--r--lib/puppet/metric.rb6
-rw-r--r--lib/puppet/statechange.rb6
-rw-r--r--lib/puppet/transaction.rb6
-rw-r--r--lib/puppet/transportable.rb6
-rw-r--r--lib/puppet/type.rb19
-rw-r--r--lib/puppet/type/component.rb2
-rw-r--r--lib/puppet/type/file.rb8
-rw-r--r--lib/puppet/type/state.rb2
11 files changed, 45 insertions, 42 deletions
diff --git a/lib/puppet/client.rb b/lib/puppet/client.rb
index 06808a4b4..15d1edf83 100644
--- a/lib/puppet/client.rb
+++ b/lib/puppet/client.rb
@@ -27,11 +27,11 @@ module Puppet
@nil = nil
@url = hash[:Server]
if hash.include?(:Listen) and hash[:Listen] == false
- Puppet.notice "We're a local client"
+ Puppet.debug "We're a local client"
@localonly = true
@driver = @url
else
- Puppet.notice "We're a networked client"
+ Puppet.debug "We're a networked client"
@localonly = false
@driver = SOAP::RPC::Driver.new(@url, 'urn:puppet-server')
@driver.add_method("getconfig", "name")
@@ -39,7 +39,7 @@ module Puppet
unless @localonly
hash.delete(:Server)
- Puppet.notice "Server is %s" % @url
+ Puppet.debug "Server is %s" % @url
hash[:BindAddress] ||= "0.0.0.0"
hash[:Port] ||= 17444
@@ -53,7 +53,7 @@ module Puppet
def getconfig
Puppet.debug "server is %s" % @url
#client.loadproperty('files/sslclient.properties')
- Puppet.notice("getting config")
+ Puppet.debug("getting config")
objects = nil
if @localonly
objects = @driver.getconfig(self)
@@ -68,7 +68,7 @@ module Puppet
# for now, just descend into the tree and perform and necessary
# manipulations
def config(tree)
- Puppet.notice("Calling config")
+ Puppet.debug("Calling config")
container = Marshal::load(tree).to_type
# this is a gross hack... but i don't see a good way around it
@@ -83,15 +83,15 @@ module Puppet
transaction.evaluate
Puppet::Metric.gather
Puppet::Metric.tally
- Metric.store
- if @@config[:rrdgraph] == true
- #Metric.store
+ if Puppet[:rrdgraph] == true
+ Metric.store
+ Metric.graph
end
self.shutdown
end
def callfunc(name,args)
- Puppet.notice("Calling callfunc on %s" % name)
+ Puppet.debug("Calling callfunc on %s" % name)
if function = Puppet::Function[name]
#Puppet.debug("calling function %s" % function)
value = function.call(args)
diff --git a/lib/puppet/event.rb b/lib/puppet/event.rb
index 86205591d..3ca76a83b 100644
--- a/lib/puppet/event.rb
+++ b/lib/puppet/event.rb
@@ -24,7 +24,7 @@ module Puppet
# this is probably wicked-slow
self.send(method.to_s + "=",value)
}
- Puppet.warning "New Subscription: '%s' => '%s'" %
+ Puppet.debug "New Subscription: '%s' => '%s'" %
[@source,@event]
end
@@ -71,16 +71,16 @@ module Puppet
@@subscriptions = []
def Event.process
- Puppet.warning "Processing events"
+ Puppet.debug "Processing events"
@@events.each { |event|
@@subscriptions.find_all { |sub|
- #Puppet.warning "Sub source: '%s'; event object: '%s'" %
+ #Puppet.debug "Sub source: '%s'; event object: '%s'" %
# [sub.source.inspect,event.object.inspect]
sub.source == event.object and
(sub.event == event.event or
sub.event == :ALL_EVENTS)
}.each { |sub|
- Puppet.notice "Found sub"
+ Puppet.debug "Found subscription to %s" % event
sub.trigger(event.transaction)
}
}
diff --git a/lib/puppet/log.rb b/lib/puppet/log.rb
index 9cfcb3c1d..9eaa32682 100644
--- a/lib/puppet/log.rb
+++ b/lib/puppet/log.rb
@@ -83,7 +83,11 @@ module Puppet
end
end
- def Log.level(level)
+ def Log.level
+ return @@levels[@@loglevel]
+ end
+
+ def Log.level=(level)
unless level.is_a?(Symbol)
level = level.intern
end
diff --git a/lib/puppet/metric.rb b/lib/puppet/metric.rb
index d66105bdf..ba2b1557e 100644
--- a/lib/puppet/metric.rb
+++ b/lib/puppet/metric.rb
@@ -22,14 +22,14 @@ module Puppet
end
def Metric.gather
- metrics = Metric.init
+ Metric.init
# first gather stats about all of the types
Puppet::Type.eachtype { |type|
type.each { |instance|
- metrics[type][:total] += 1
+ @@typemetrics[type][:total] += 1
if instance.managed
- metrics[type][:managed] += 1
+ @@typemetrics[type][:managed] += 1
end
}
}
diff --git a/lib/puppet/statechange.rb b/lib/puppet/statechange.rb
index 4b0cdda5a..f04c40f00 100644
--- a/lib/puppet/statechange.rb
+++ b/lib/puppet/statechange.rb
@@ -25,7 +25,7 @@ module Puppet
#---------------------------------------------------------------
def go
if @state.noop
- #Puppet.notice "%s is noop" % @state
+ #Puppet.debug "%s is noop" % @state
return nil
end
@@ -37,7 +37,7 @@ module Puppet
if event.nil?
event = @state.parent.class.name.id2name + "_changed"
elsif ! event.is_a?(Symbol)
- Puppet.notice "State '%s' returned invalid event '%s'; resetting to default" %
+ Puppet.warning "State '%s' returned invalid event '%s'; resetting to default" %
[@state.class,event]
event = @state.parent.class.name.id2name + "_changed"
@@ -72,7 +72,7 @@ module Puppet
#---------------------------------------------------------------
def forward
- #Puppet.notice "moving change forward"
+ #Puppet.debug "moving change forward"
unless defined? @transaction
raise "StateChange '%s' tried to be executed outside of transaction" %
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index 03f965a76..2b7d43f8f 100644
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@ -42,7 +42,7 @@ class Transaction
# thus, an object gets defined, then mentioned as a dependency, and the objects
# are synced in that order automatically
def evaluate
- Puppet.notice "executing %s changes or transactions" % @changes.length
+ Puppet.debug "executing %s changes or transactions" % @changes.length
return @changes.collect { |change|
if change.is_a?(Puppet::StateChange)
@@ -147,7 +147,7 @@ class Transaction
#---------------------------------------------------------------
def triggercount(sub)
- Puppet.notice "Triggercount on %s is %s" % [sub,@triggered[sub]]
+ Puppet.debug "Triggercount on %s is %s" % [sub,@triggered[sub]]
return @triggered[sub]
end
#---------------------------------------------------------------
@@ -155,7 +155,7 @@ class Transaction
#---------------------------------------------------------------
def triggered(sub)
@triggered[sub] += 1
- Puppet.notice "%s was triggered; count is %s" % [sub,@triggered[sub]]
+ Puppet.debug "%s was triggered; count is %s" % [sub,@triggered[sub]]
end
#---------------------------------------------------------------
end
diff --git a/lib/puppet/transportable.rb b/lib/puppet/transportable.rb
index 519ca7460..c803a9e3d 100644
--- a/lib/puppet/transportable.rb
+++ b/lib/puppet/transportable.rb
@@ -132,12 +132,12 @@ module Puppet
}
if defined? @parameters
@parameters.each { |param,value|
- Puppet.warning "Defining %s on %s of type %s" %
+ Puppet.debug "Defining %s on %s of type %s" %
[param,@name,@type]
hash[param] = value
}
else
- Puppet.warning "%s has no parameters" % @name
+ Puppet.debug "%s has no parameters" % @name
end
container = Puppet::Component.new(hash)
nametable = {}
@@ -165,7 +165,7 @@ module Puppet
# don't rename; this shouldn't be possible anyway
next if var == :name
- Puppet.notice "Adding %s to %s" % [var,name]
+ Puppet.debug "Adding %s to %s" % [var,name]
# override any existing values
object[var] = value
}
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 483d94d76..0eee5dbe0 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -152,7 +152,7 @@ class Type < Puppet::Element
def Type.inherited(sub)
sub.initvars
- #Puppet.notice("subtype %s(%s) just created" % [sub,sub.superclass])
+ #Puppet.debug("subtype %s(%s) just created" % [sub,sub.superclass])
# add it to the master list
# unfortunately we can't yet call sub.name, because the #inherited
# method gets called before any commands in the class definition
@@ -200,7 +200,7 @@ class Type < Puppet::Element
raise "Type.newtype called, but I don't know why"
@@typeary.push(type)
if @@typehash.has_key?(type.name)
- Puppet.notice("Redefining object type %s" % type.name)
+ Puppet.debug("Redefining object type %s" % type.name)
end
@@typehash[type.name] = type
end
@@ -258,7 +258,7 @@ class Type < Puppet::Element
# remove all type instances
def Type.allclear
@@typeary.each { |subtype|
- Puppet.notice "Clearing %s of objects" % subtype
+ Puppet.debug "Clearing %s of objects" % subtype
subtype.clear
}
end
@@ -276,7 +276,7 @@ class Type < Puppet::Element
#---------------------------------------------------------------
def Type.each
return unless defined? @objects
- @objects.each { |instance|
+ @objects.each { |name,instance|
yield instance
}
end
@@ -344,7 +344,7 @@ class Type < Puppet::Element
#---------------------------------------------------------------
# this is probably only used by FileRecord objects
def Type.parameters=(params)
- Puppet.notice "setting parameters to [%s]" % params.join(" ")
+ Puppet.debug "setting parameters to [%s]" % params.join(" ")
@parameters = params.collect { |param|
if param.class == Symbol
param
@@ -443,7 +443,7 @@ class Type < Puppet::Element
:parent => self,
:should => value
)
- #Puppet.notice "Adding parent to %s" % mname
+ #Puppet.debug "Adding parent to %s" % mname
#@states[mname].parent = self
end
end
@@ -556,7 +556,7 @@ class Type < Puppet::Element
}
# add this object to the specific class's list of objects
- #Puppet.notice("Adding [%s] to %s" % [self.name,self.class])
+ #Puppet.debug("Adding [%s] to %s" % [self.name,self.class])
self.class[self.name] = self
# and then add it to the master list
@@ -619,15 +619,14 @@ class Type < Puppet::Element
if defined? @managed
return @managed
else
+ @managed = false
self.states.each { |state|
if state.should
@managed = true
- else
- @managed = false
end
}
+ return @managed
end
- return @managed
end
#---------------------------------------------------------------
diff --git a/lib/puppet/type/component.rb b/lib/puppet/type/component.rb
index 74db00d00..cd1f65c6c 100644
--- a/lib/puppet/type/component.rb
+++ b/lib/puppet/type/component.rb
@@ -42,7 +42,7 @@ module Puppet
def push(*ary)
ary.each { |child|
unless child.is_a?(Puppet::Element)
- Puppet.notice "Got object of type %s" % child.class
+ Puppet.debug "Got object of type %s" % child.class
raise "Containers can only contain Puppet::Elements"
end
@children.push child
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index f9d966608..28ac59447 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -155,7 +155,7 @@ module Puppet
if @is == -1
self.parent.stat(true)
self.retrieve
- Puppet.notice "%s: after refresh, is '%s'" % [self.class.name,@is]
+ Puppet.debug "%s: after refresh, is '%s'" % [self.class.name,@is]
end
unless self.parent.stat
@@ -206,7 +206,7 @@ module Puppet
if @is == -1
self.parent.stat(true)
self.retrieve
- Puppet.notice "%s: after refresh, is '%s'" % [self.class.name,@is]
+ Puppet.debug "%s: after refresh, is '%s'" % [self.class.name,@is]
end
unless self.parent.stat
@@ -243,7 +243,7 @@ module Puppet
unless defined? @is or @is == -1
self.parent.stat(true)
self.retrieve
- Puppet.notice "%s: should is '%s'" % [self.class.name,self.should]
+ Puppet.debug "%s: should is '%s'" % [self.class.name,self.should]
end
tmp = 0
if self.is == true
@@ -303,7 +303,7 @@ module Puppet
if @is == -1
self.parent.stat(true)
self.retrieve
- Puppet.notice "%s: after refresh, is '%s'" % [self.class.name,@is]
+ Puppet.debug "%s: after refresh, is '%s'" % [self.class.name,@is]
end
unless self.parent.stat
diff --git a/lib/puppet/type/state.rb b/lib/puppet/type/state.rb
index 306b2e5ce..8ba798b1e 100644
--- a/lib/puppet/type/state.rb
+++ b/lib/puppet/type/state.rb
@@ -93,7 +93,7 @@ class State < Puppet::Element
@noop = false
end
tmp = @noop || self.parent.noop || Puppet[:noop] || false
- Puppet.notice "noop is %s" % tmp
+ Puppet.debug "noop is %s" % tmp
return tmp
end
#---------------------------------------------------------------