Class: Chef::GELF::Handler
- Inherits:
-
Handler
- Object
- Handler
- Chef::GELF::Handler
- Defined in:
- lib/chef/gelf.rb
Instance Attribute Summary collapse
-
#notifier ⇒ Object
readonly
Returns the value of attribute notifier.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Handler
constructor
A new instance of Handler.
- #report ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Handler
Returns a new instance of Handler.
15 16 17 18 19 20 |
# File 'lib/chef/gelf.rb', line 15 def initialize( = {}) self. = Chef::Log.debug "Initialised GELF handler for gelf://#{self.[:server]}:#{self.[:port]}/#{self.[:facility]}" @notifier = ::GELF::Notifier.new(self.[:server], self.[:port], 'WAN', :facility => self.[:facility]) end |
Instance Attribute Details
#notifier ⇒ Object (readonly)
Returns the value of attribute notifier.
8 9 10 |
# File 'lib/chef/gelf.rb', line 8 def notifier @notifier end |
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/chef/gelf.rb', line 9 def @options end |
Instance Method Details
#report ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/chef/gelf.rb', line 22 def report Chef::Log.debug "Reporting #{run_status.inspect}" if run_status.failed? Chef::Log.debug "Notifying Graylog server of failure." @notifier.notify!(:short_message => "Chef run failed on #{@notifier.host}. Updated #{changes[:count]} resources.", :full_message => run_status.formatted_exception + "\n" + Array(backtrace).join("\n") + changes[:message], :level => ::GELF::Levels::FATAL, :host => host_name) else Chef::Log.debug "Notifying Graylog server of success." @notifier.notify!(:short_message => "Chef run completed on #{node.name} in #{elapsed_time}. Updated #{changes[:count]} resources.", :full_message => changes[:message], :level => ::GELF::Levels::INFO, :host => host_name) end end |