Class: CFTools::Tunnel::LogEntry
- Inherits:
-
Object
- Object
- CFTools::Tunnel::LogEntry
- Defined in:
- lib/tools-cf-plugin/tunnel/log_entry.rb
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(label, line, stream) ⇒ LogEntry
constructor
A new instance of LogEntry.
- #log_level ⇒ Object
- #message ⇒ Object
- #timestamp ⇒ Object
Constructor Details
#initialize(label, line, stream) ⇒ LogEntry
Returns a new instance of LogEntry.
9 10 11 12 13 14 |
# File 'lib/tools-cf-plugin/tunnel/log_entry.rb', line 9 def initialize(label, line, stream) @label = label @line = line @stream = stream @fallback_timestamp = Time.now end |
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
7 8 9 |
# File 'lib/tools-cf-plugin/tunnel/log_entry.rb', line 7 def label @label end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
7 8 9 |
# File 'lib/tools-cf-plugin/tunnel/log_entry.rb', line 7 def line @line end |
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
7 8 9 |
# File 'lib/tools-cf-plugin/tunnel/log_entry.rb', line 7 def stream @stream end |
Instance Method Details
#data ⇒ Object
29 30 31 32 33 |
# File 'lib/tools-cf-plugin/tunnel/log_entry.rb', line 29 def data json = JSON.parse(@line) json["data"] rescue JSON::ParserError end |
#log_level ⇒ Object
23 24 25 26 27 |
# File 'lib/tools-cf-plugin/tunnel/log_entry.rb', line 23 def log_level json = JSON.parse(@line) json["log_level"] rescue JSON::ParserError end |
#message ⇒ Object
16 17 18 19 20 21 |
# File 'lib/tools-cf-plugin/tunnel/log_entry.rb', line 16 def json = JSON.parse(@line) json["message"] rescue JSON::ParserError @line end |
#timestamp ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/tools-cf-plugin/tunnel/log_entry.rb', line 35 def json = JSON.parse(@line) = json["timestamp"] case when String Time.parse() when Numeric Time.at() else @fallback_timestamp end rescue JSON::ParserError @fallback_timestamp end |