Class: Puppet::Util::Instrumentation::Listener
Constant Summary
Constants included
from Indirector
Indirector::BadNameRegexp
AbsolutePathPosix, AbsolutePathWindows, DEFAULT_POSIX_MODE, DEFAULT_WINDOWS_MODE
Constants included
from POSIX
POSIX::LOCALE_ENV_VARS, POSIX::USER_ENV_VARS
SymbolicFileMode::SetGIDBit, SymbolicFileMode::SetUIDBit, SymbolicFileMode::StickyBit, SymbolicFileMode::SymbolicMode, SymbolicFileMode::SymbolicSpecialToBit
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Indirector
configure_routes, indirects
Methods included from Warnings
clear_warnings, debug_once, notice_once, warnonce
absolute_path?, activerecord_version, benchmark, binread, chuser, classproxy, deterministic_rand, execfail, execpipe, execute, exit_on_fail, logmethods, memory, path_to_uri, pretty_backtrace, proxy, replace_file, safe_posix_fork, symbolizehash, thinmark, uri_to_path, which, withenv, withumask
Methods included from POSIX
#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid
#normalize_symbolic_mode, #symbolic_mode_to_int, #valid_symbolic_mode?
Constructor Details
#initialize(listener, pattern = nil, enabled = false) ⇒ Listener
Returns a new instance of Listener.
15
16
17
18
19
20
|
# File 'lib/puppet/util/instrumentation/listener.rb', line 15
def initialize(listener, pattern = nil, enabled = false)
@pattern = pattern.is_a?(Symbol) ? pattern.to_s : pattern
raise "Listener isn't a correct listener (it doesn't provide the notify method)" unless listener.respond_to?(:notify)
@listener = listener
@enabled = enabled
end
|
Instance Attribute Details
13
14
15
|
# File 'lib/puppet/util/instrumentation/listener.rb', line 13
def enabled
@enabled
end
|
12
13
14
|
# File 'lib/puppet/util/instrumentation/listener.rb', line 12
def listener
@listener
end
|
12
13
14
|
# File 'lib/puppet/util/instrumentation/listener.rb', line 12
def pattern
@pattern
end
|
Class Method Details
.from_data_hash(data) ⇒ Object
63
64
65
66
|
# File 'lib/puppet/util/instrumentation/listener.rb', line 63
def self.from_data_hash(data)
result = Puppet::Util::Instrumentation[data["name"]]
self.new(result.listener, result.pattern, data["enabled"])
end
|
.from_pson(data) ⇒ Object
68
69
70
71
|
# File 'lib/puppet/util/instrumentation/listener.rb', line 68
def self.from_pson(data)
Puppet.deprecation_warning("from_pson is being removed in favour of from_data_hash.")
self.from_data_hash(data)
end
|
Instance Method Details
40
41
42
|
# File 'lib/puppet/util/instrumentation/listener.rb', line 40
def data
{ :data => @listener.data }
end
|
#enabled? ⇒ Boolean
32
33
34
|
# File 'lib/puppet/util/instrumentation/listener.rb', line 32
def enabled?
!!@enabled
end
|
#listen_to?(label) ⇒ Boolean
28
29
30
|
# File 'lib/puppet/util/instrumentation/listener.rb', line 28
def listen_to?(label)
enabled? and (!@pattern || @pattern === label.to_s)
end
|
36
37
38
|
# File 'lib/puppet/util/instrumentation/listener.rb', line 36
def name
@listener.name.to_s
end
|
#notify(label, event, data) ⇒ Object
22
23
24
25
26
|
# File 'lib/puppet/util/instrumentation/listener.rb', line 22
def notify(label, event, data)
listener.notify(label, event, data)
rescue => e
warnonce("Error during instrumentation notification: #{e}")
end
|
#to_data_hash ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/puppet/util/instrumentation/listener.rb', line 44
def to_data_hash
{
:name => name,
:pattern => pattern,
:enabled => enabled?
}
end
|
#to_pson(*args) ⇒ Object
59
60
61
|
# File 'lib/puppet/util/instrumentation/listener.rb', line 59
def to_pson(*args)
to_pson_data_hash.to_pson(*args)
end
|
#to_pson_data_hash ⇒ Object
52
53
54
55
56
57
|
# File 'lib/puppet/util/instrumentation/listener.rb', line 52
def to_pson_data_hash
{
:document_type => "Puppet::Util::Instrumentation::Listener",
:data => to_data_hash,
}
end
|