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
-
#count ⇒ Integer
How many times this message was repeated.
-
#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.
-
#type ⇒ Symbol
readonly
The documented values are :assert, :dir, :dirxml, :endGroup, :log, :startGroup, :startGroupCollapsed, and :trace.
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
@
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/webkit_remote/client/console.rb', line 107 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 @count = ['repeatCount'] ? ['repeatCount'].to_i : 1 if ['source'] @reason = ['source'].gsub('-', '_').to_sym else @reason = :other end @stack_trace = self.class.parse_stack_trace ['stackTrace'] @text = ['text'] @type = ['type'] ? ['type'].to_sym : nil @source_url = ['url'] end |
Instance Attribute Details
#count ⇒ Integer
Returns how many times this message was repeated.
72 73 74 |
# File 'lib/webkit_remote/client/console.rb', line 72 def count @count end |
#level ⇒ Symbol (readonly)
The documented values are :debug, :error, :log, :tip, and :warning.
69 70 71 |
# File 'lib/webkit_remote/client/console.rb', line 69 def level @level end |
#network_resource ⇒ WebkitRemote::Client::NetworkResource (readonly)
This is set for console messages that indicate network errors.
84 85 86 |
# File 'lib/webkit_remote/client/console.rb', line 84 def network_resource @network_resource end |
#params ⇒ Array<WebkitRemote::Client::JsObject> (readonly)
Returns extra arguments given to the message.
64 65 66 |
# File 'lib/webkit_remote/client/console.rb', line 64 def params @params end |
#reason ⇒ Symbol (readonly)
The documented values are :console_api, :html, :javascript, :network,
:other, :wml, and :xml.
78 79 80 |
# File 'lib/webkit_remote/client/console.rb', line 78 def reason @reason end |
#source_line ⇒ Integer (readonly)
Returns the line number of the statement that caused this message.
96 97 98 |
# File 'lib/webkit_remote/client/console.rb', line 96 def source_line @source_line end |
#source_url ⇒ String (readonly)
Returns the URL of the file that caused this message.
93 94 95 |
# File 'lib/webkit_remote/client/console.rb', line 93 def source_url @source_url end |
#stack_trace ⇒ Array<Hash<Symbol, Object>> (readonly)
Returns JavaScript stack trace to the statement that caused this message.
100 101 102 |
# File 'lib/webkit_remote/client/console.rb', line 100 def stack_trace @stack_trace end |
#text ⇒ String (readonly)
Returns the message text.
60 61 62 |
# File 'lib/webkit_remote/client/console.rb', line 60 def text @text end |
#type ⇒ Symbol (readonly)
The documented values are :assert, :dir, :dirxml, :endGroup, :log,
:startGroup, :startGroupCollapsed, and :trace.
90 91 92 |
# File 'lib/webkit_remote/client/console.rb', line 90 def type @type end |
Class Method Details
.parse_stack_trace(raw_stack_trace) ⇒ Array<Symbol, Object>
Parses a StackTrace object returned by a RPC request.
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/webkit_remote/client/console.rb', line 150 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.
137 138 139 140 141 142 143 |
# File 'lib/webkit_remote/client/console.rb', line 137 def release_params @params.each do |param| if param.kind_of?(WebkitRemote::Client::JsObject) param.release end end end |