Class: Chef::Handler::Graylog::GelfMessage
- Inherits:
-
Object
- Object
- Chef::Handler::Graylog::GelfMessage
- Defined in:
- lib/chef/handler/graylog/gelf_message.rb
Instance Attribute Summary collapse
-
#full_message ⇒ Object
writeonly
Sets the attribute full_message.
-
#message ⇒ Object
writeonly
Sets the attribute message.
Instance Method Summary collapse
- #add_field(key, value) ⇒ Object
-
#initialize(node, field_prefix, timestamp = Time.now.to_f) ⇒ GelfMessage
constructor
A new instance of GelfMessage.
- #to_hash ⇒ Object
Constructor Details
#initialize(node, field_prefix, timestamp = Time.now.to_f) ⇒ GelfMessage
Returns a new instance of GelfMessage.
7 8 9 10 11 12 13 |
# File 'lib/chef/handler/graylog/gelf_message.rb', line 7 def initialize(node, field_prefix, = Time.now.to_f) @node = node @field_prefix = field_prefix = @version = '1.1' @fields = {} end |
Instance Attribute Details
#full_message=(value) ⇒ Object (writeonly)
Sets the attribute full_message
5 6 7 |
# File 'lib/chef/handler/graylog/gelf_message.rb', line 5 def (value) = value end |
#message=(value) ⇒ Object (writeonly)
Sets the attribute message
5 6 7 |
# File 'lib/chef/handler/graylog/gelf_message.rb', line 5 def (value) = value end |
Instance Method Details
#add_field(key, value) ⇒ Object
15 16 17 |
# File 'lib/chef/handler/graylog/gelf_message.rb', line 15 def add_field(key, value) @fields["_#{[@field_prefix, key].compact.join('_')}"] = value end |
#to_hash ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/chef/handler/graylog/gelf_message.rb', line 19 def to_hash hash = { 'version' => @version, 'timestamp' => , 'host' => @node.name, 'short_message' => } hash['full_message'] = if @fields.merge(hash) end |