Class: LogStasher::Event
- Inherits:
-
Object
- Object
- LogStasher::Event
- Defined in:
- lib/logstasher/event.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(data = {}) ⇒ Event
constructor
A new instance of Event.
- #to_json(*args) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(data = {}) ⇒ Event
Returns a new instance of Event.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/logstasher/event.rb', line 7 def initialize(data = {}) @cancelled = false @data = data if data.include?('@timestamp') t = data['@timestamp'] data['@timestamp'] = Time.parse(t).gmtime.iso8601(3) if t.is_a?(String) else data['@timestamp'] = ::Time.now.utc.iso8601(3) end data['@version'] = '1' unless @data.include?('@version') end |
Instance Method Details
#[](key) ⇒ Object
28 29 30 |
# File 'lib/logstasher/event.rb', line 28 def [](key) @data[key] end |
#to_json(*args) ⇒ Object
24 25 26 |
# File 'lib/logstasher/event.rb', line 24 def to_json(*args) @data.to_json(*args) end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/logstasher/event.rb', line 20 def to_s to_json.to_s end |