Class: Microsandbox::LogEntry
- Inherits:
-
Object
- Object
- Microsandbox::LogEntry
- Defined in:
- lib/microsandbox/log_entry.rb
Overview
A single captured log entry, returned by Sandbox#logs.
Instance Attribute Summary collapse
-
#cursor ⇒ String
readonly
Opaque resume cursor token.
-
#data ⇒ String
readonly
Raw captured bytes (ASCII-8BIT).
-
#session_id ⇒ Integer?
readonly
Relay-monotonic session id (nil for system markers).
-
#source ⇒ Symbol
readonly
One of :stdout, :stderr, :output, :system.
Instance Method Summary collapse
-
#initialize(entry) ⇒ LogEntry
constructor
A new instance of LogEntry.
- #inspect ⇒ Object
-
#text ⇒ String
The captured bytes decoded as UTF-8 (lenient).
-
#timestamp ⇒ Time
Wall-clock capture time.
Constructor Details
#initialize(entry) ⇒ LogEntry
Returns a new instance of LogEntry.
15 16 17 18 19 20 21 |
# File 'lib/microsandbox/log_entry.rb', line 15 def initialize(entry) @timestamp_ms = entry["timestamp_ms"] @source = entry["source"].to_sym @session_id = entry["session_id"] @cursor = entry["cursor"] @data = entry["data"] end |
Instance Attribute Details
#cursor ⇒ String (readonly)
Returns opaque resume cursor token.
11 12 13 |
# File 'lib/microsandbox/log_entry.rb', line 11 def cursor @cursor end |
#data ⇒ String (readonly)
Returns raw captured bytes (ASCII-8BIT).
13 14 15 |
# File 'lib/microsandbox/log_entry.rb', line 13 def data @data end |
#session_id ⇒ Integer? (readonly)
Returns relay-monotonic session id (nil for system markers).
9 10 11 |
# File 'lib/microsandbox/log_entry.rb', line 9 def session_id @session_id end |
#source ⇒ Symbol (readonly)
Returns one of :stdout, :stderr, :output, :system.
7 8 9 |
# File 'lib/microsandbox/log_entry.rb', line 7 def source @source end |
Instance Method Details
#inspect ⇒ Object
33 34 35 36 |
# File 'lib/microsandbox/log_entry.rb', line 33 def inspect "#<Microsandbox::LogEntry source=#{@source} session_id=#{@session_id} " \ "len=#{@data.bytesize}>" end |
#text ⇒ String
Returns the captured bytes decoded as UTF-8 (lenient).
29 30 31 |
# File 'lib/microsandbox/log_entry.rb', line 29 def text @data.dup.force_encoding(Encoding::UTF_8) end |
#timestamp ⇒ Time
Returns wall-clock capture time.
24 25 26 |
# File 'lib/microsandbox/log_entry.rb', line 24 def Time.at(@timestamp_ms / 1000.0) end |