Class: Ferrum::Log::Annotated
- Inherits:
-
Object
- Object
- Ferrum::Log::Annotated
- Includes:
- Paint
- Defined in:
- lib/ferrum/log/annotated.rb,
sig/ferrum/log/annotated.rbs
Overview
Formats CDP messages one line each, the JSON whole after a header: the
direction, the elapsed time, the command id and method. Received
messages are indented under the commands sent. A response also
names the method of its command and how long the answer took. Picked
with FERRUM_LOG_FORMAT=annotated.
Constant Summary
Constants included from Paint
Instance Method Summary collapse
-
#initialize(color: false) ⇒ Annotated
constructor
A new instance of Annotated.
- #received(message, raw, elapsed, command = nil) ⇒ String
- #sent(message, elapsed) ⇒ String
Methods included from Paint
Constructor Details
#initialize(color: false) ⇒ Annotated
Returns a new instance of Annotated.
17 18 19 |
# File 'lib/ferrum/log/annotated.rb', line 17 def initialize(color: false) @color = color end |
Instance Method Details
#received(message, raw, elapsed, command = nil) ⇒ String
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ferrum/log/annotated.rb', line 42 def received(, raw, elapsed, command = nil) return line(" ", paint("◀", :magenta), time(elapsed), raw) unless return event(, elapsed) unless .key?("id") method, duration = command error = ["error"] line(" ", paint("◀", error ? :red : :green), time(elapsed), "##{['id']}", paint(method, :bold), duration && "#{(duration * 1000).round}ms", json(error || ["result"]), session(["sessionId"])) end |
#sent(message, elapsed) ⇒ String
26 27 28 29 |
# File 'lib/ferrum/log/annotated.rb', line 26 def sent(, elapsed) line(paint("▶", :cyan), time(elapsed), "##{[:id]}", paint([:method], :bold), json([:params]), session([:sessionId])) end |