Class: Woodchuck::Event
- Inherits:
-
Object
- Object
- Woodchuck::Event
- Defined in:
- lib/woodchuck/event.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#host ⇒ Object
Returns the value of attribute host.
-
#line ⇒ Object
Returns the value of attribute line.
-
#message ⇒ Object
Returns the value of attribute message.
-
#path ⇒ Object
Returns the value of attribute path.
-
#source ⇒ Object
Returns the value of attribute source.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
Instance Method Summary collapse
-
#initialize(path, line) ⇒ Event
constructor
A new instance of Event.
- #method_missing(symbol, *args, &block) ⇒ Object
- #to_hash ⇒ Object
- #to_json(*args) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(path, line) ⇒ Event
Returns a new instance of Event.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/woodchuck/event.rb', line 7 def initialize(path, line) @path = path @line = line @host = Socket.gethostname @timestamp = Time.now.utc.iso8601(6) @source = Addressable::URI.new(:scheme => 'file', :host => host, :path => path) @message = line.strip @fields = {} @tags = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args, &block) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/woodchuck/event.rb', line 18 def method_missing(symbol, *args, &block) if to_hash.has_key?(symbol) to_hash else super(symbol, *args, &block) end end |
Instance Attribute Details
#fields ⇒ Object
Returns the value of attribute fields.
5 6 7 |
# File 'lib/woodchuck/event.rb', line 5 def fields @fields end |
#host ⇒ Object
Returns the value of attribute host.
5 6 7 |
# File 'lib/woodchuck/event.rb', line 5 def host @host end |
#line ⇒ Object
Returns the value of attribute line.
5 6 7 |
# File 'lib/woodchuck/event.rb', line 5 def line @line end |
#message ⇒ Object
Returns the value of attribute message.
5 6 7 |
# File 'lib/woodchuck/event.rb', line 5 def @message end |
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'lib/woodchuck/event.rb', line 5 def path @path end |
#source ⇒ Object
Returns the value of attribute source.
5 6 7 |
# File 'lib/woodchuck/event.rb', line 5 def source @source end |
#tags ⇒ Object
Returns the value of attribute tags.
5 6 7 |
# File 'lib/woodchuck/event.rb', line 5 def @tags end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
5 6 7 |
# File 'lib/woodchuck/event.rb', line 5 def @timestamp end |
Instance Method Details
#to_hash ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/woodchuck/event.rb', line 26 def to_hash { '@source' => source.to_s, '@type' => source.scheme, '@tags' => , '@fields' => fields, '@timestamp' => , '@source_host' => host, '@source_path' => path, '@message' => } end |
#to_json(*args) ⇒ Object
39 40 41 |
# File 'lib/woodchuck/event.rb', line 39 def to_json(*args) to_hash.to_json(*args) end |
#to_s ⇒ Object
43 44 45 |
# File 'lib/woodchuck/event.rb', line 43 def to_s to_json end |