Class: LogBench::Log::Entry
- Inherits:
-
Object
- Object
- LogBench::Log::Entry
- Defined in:
- lib/log_bench/log/entry.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#raw_line ⇒ Object
readonly
Returns the value of attribute raw_line.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#timing ⇒ Object
readonly
Returns the value of attribute timing.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #http_request? ⇒ Boolean
-
#initialize(raw_line) ⇒ Entry
constructor
A new instance of Entry.
- #related_log? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(raw_line) ⇒ Entry
Returns a new instance of Entry.
8 9 10 11 12 13 |
# File 'lib/log_bench/log/entry.rb', line 8 def initialize(raw_line) self.raw_line = raw_line.strip self. = Time.now self.type = :unknown parse! end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
6 7 8 |
# File 'lib/log_bench/log/entry.rb', line 6 def content @content end |
#raw_line ⇒ Object
Returns the value of attribute raw_line.
6 7 8 |
# File 'lib/log_bench/log/entry.rb', line 6 def raw_line @raw_line end |
#request_id ⇒ Object
Returns the value of attribute request_id.
6 7 8 |
# File 'lib/log_bench/log/entry.rb', line 6 def request_id @request_id end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
6 7 8 |
# File 'lib/log_bench/log/entry.rb', line 6 def @timestamp end |
#timing ⇒ Object
Returns the value of attribute timing.
6 7 8 |
# File 'lib/log_bench/log/entry.rb', line 6 def timing @timing end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/log_bench/log/entry.rb', line 6 def type @type end |
Class Method Details
.build(raw_line) ⇒ Object
15 16 17 |
# File 'lib/log_bench/log/entry.rb', line 15 def self.build(raw_line) new(raw_line) if parseable?(raw_line) end |
.parseable?(line) ⇒ Boolean
19 20 21 22 23 24 |
# File 'lib/log_bench/log/entry.rb', line 19 def self.parseable?(line) data = JSON.parse(line.strip) data.is_a?(Hash) rescue JSON::ParserError false end |
Instance Method Details
#http_request? ⇒ Boolean
26 27 28 |
# File 'lib/log_bench/log/entry.rb', line 26 def http_request? type == :http_request end |
#related_log? ⇒ Boolean
30 31 32 |
# File 'lib/log_bench/log/entry.rb', line 30 def !http_request? end |
#to_h ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/log_bench/log/entry.rb', line 34 def to_h { raw: raw_line, timestamp: , request_id: request_id, type: type } end |