Class: WebkitRemote::Client::ConsoleMessage
- Inherits:
-
Object
- Object
- WebkitRemote::Client::ConsoleMessage
- Defined in:
- lib/webkit_remote/client/console.rb
Overview
Data about an entry in the debugger console.
Instance Attribute Summary collapse
-
#level ⇒ Symbol
readonly
The documented values are :debug, :error, :log, :tip, and :warning.
-
#network_resource ⇒ WebkitRemote::Client::NetworkResource
readonly
This is set for console messages that indicate network errors.
-
#params ⇒ Array<WebkitRemote::Client::JsObject>
readonly
Extra arguments given to the message.
-
#reason ⇒ Symbol
readonly
The documented values are :console_api, :html, :javascript, :network, :other, :wml, and :xml.
-
#source_line ⇒ Integer
readonly
The line number of the statement that caused this message.
-
#source_url ⇒ String
readonly
The URL of the file that caused this message.
-
#stack_trace ⇒ Array<Hash<Symbol, Object>>
readonly
JavaScript stack trace to the statement that caused this message.
-
#text ⇒ String
readonly
The message text.
Class Method Summary collapse
-
.parse_stack_trace(raw_stack_trace) ⇒ Array<Symbol, Object>
Parses a StackTrace object returned by a RPC request.
Instance Method Summary collapse
-
#initialize(raw_message, client) ⇒ ConsoleMessage
constructor
@.
-
#release_params ⇒ Object
Releases the JavaScript objects referenced by this message’s parameters.
Constructor Details
#initialize(raw_message, client) ⇒ ConsoleMessage
@
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/webkit_remote/client/console.rb', line 93 def initialize(, client) @level = (['level'] || 'error').to_sym @source_line = ['line'] ? ['line'].to_i : nil if ['networkRequestId'] @network_resource = client.network_resource ['networkRequestId'] else @network_resource = nil end if ['parameters'] @params = ['parameters'].map do |raw_object| WebkitRemote::Client::JsObject.for raw_object, client, nil end else @params = [] end @params.freeze if ['source'] @reason = ['source'].gsub('-', '_').to_sym else @reason = :other end @stack_trace = self.class.parse_stack_trace ['stackTrace'] @text = ['text'] @source_url = ['url'] end |
Instance Attribute Details
#level ⇒ Symbol (readonly)
The documented values are :debug, :error, :log, :tip, and :warning.
64 65 66 |
# File 'lib/webkit_remote/client/console.rb', line 64 def level @level end |
#network_resource ⇒ WebkitRemote::Client::NetworkResource (readonly)
This is set for console messages that indicate network errors.
76 77 78 |
# File 'lib/webkit_remote/client/console.rb', line 76 def network_resource @network_resource end |
#params ⇒ Array<WebkitRemote::Client::JsObject> (readonly)
Returns extra arguments given to the message.
59 60 61 |
# File 'lib/webkit_remote/client/console.rb', line 59 def params @params end |
#reason ⇒ Symbol (readonly)
The documented values are :console_api, :html, :javascript, :network,
:other, :wml, and :xml.
70 71 72 |
# File 'lib/webkit_remote/client/console.rb', line 70 def reason @reason end |
#source_line ⇒ Integer (readonly)
Returns the line number of the statement that caused this message.
82 83 84 |
# File 'lib/webkit_remote/client/console.rb', line 82 def source_line @source_line end |
#source_url ⇒ String (readonly)
Returns the URL of the file that caused this message.
79 80 81 |
# File 'lib/webkit_remote/client/console.rb', line 79 def source_url @source_url end |
#stack_trace ⇒ Array<Hash<Symbol, Object>> (readonly)
Returns JavaScript stack trace to the statement that caused this message.
86 87 88 |
# File 'lib/webkit_remote/client/console.rb', line 86 def stack_trace @stack_trace end |
#text ⇒ String (readonly)
Returns the message text.
55 56 57 |
# File 'lib/webkit_remote/client/console.rb', line 55 def text @text end |
Class Method Details
.parse_stack_trace(raw_stack_trace) ⇒ Array<Symbol, Object>
Parses a StackTrace object returned by a RPC request.
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/webkit_remote/client/console.rb', line 134 def self.parse_stack_trace(raw_stack_trace) return nil unless raw_stack_trace raw_stack_trace.map do |raw_frame| frame = {} if raw_frame['columnNumber'] frame[:column] = raw_frame['columnNumber'].to_i end if raw_frame['lineNumber'] frame[:line] = raw_frame['lineNumber'].to_i end if raw_frame['functionName'] frame[:function] = raw_frame['functionName'] end if raw_frame['url'] frame[:url] = raw_frame['url'] end frame end end |
Instance Method Details
#release_params ⇒ Object
Releases the JavaScript objects referenced by this message’s parameters.
121 122 123 124 125 126 127 |
# File 'lib/webkit_remote/client/console.rb', line 121 def release_params @params.each do |param| if param.kind_of?(WebkitRemote::Client::JsObject) param.release end end end |