Class: Logn::Event
- Inherits:
-
Object
- Object
- Logn::Event
- Defined in:
- lib/logn.rb
Constant Summary collapse
- LOG_LINE_REGEX =
/^ (?<level>\w) ,\s \[ (?<timestamp>\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d.\d+) \s \#(?<pid>\d+) \] \s+ (?<severity>\w+) \s--\s:\s (?<sender>[\w.]+) (?<event>:\w+)? \s (?<json>.*) $/x
Instance Method Summary collapse
- #event ⇒ Object
-
#initialize(line) ⇒ Event
constructor
A new instance of Event.
- #level ⇒ Object
- #metadata ⇒ Object
- #pid ⇒ Object
- #sender ⇒ Object
- #severity ⇒ Object
- #timestamp ⇒ Object
Constructor Details
#initialize(line) ⇒ Event
Returns a new instance of Event.
100 101 102 |
# File 'lib/logn.rb', line 100 def initialize(line) @line = line end |
Instance Method Details
#event ⇒ Object
124 125 126 |
# File 'lib/logn.rb', line 124 def event @event ||= (match[:event] and match[:event].gsub(/^:/, '').downcase.to_sym) end |
#level ⇒ Object
104 105 106 |
# File 'lib/logn.rb', line 104 def level match[:level] end |
#metadata ⇒ Object
128 129 130 131 |
# File 'lib/logn.rb', line 128 def return nil unless match[:json] ||= JSON.parse(match[:json]) end |
#pid ⇒ Object
112 113 114 |
# File 'lib/logn.rb', line 112 def pid match[:pid] end |
#sender ⇒ Object
120 121 122 |
# File 'lib/logn.rb', line 120 def sender match[:sender] end |
#severity ⇒ Object
116 117 118 |
# File 'lib/logn.rb', line 116 def severity @severity ||= match[:severity].downcase.to_sym end |
#timestamp ⇒ Object
108 109 110 |
# File 'lib/logn.rb', line 108 def ||= Time.iso8601(match[:timestamp]) end |