Web Inspector: Include target identifier in protocol logging
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Nov 2018 21:59:06 +0000 (21:59 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Nov 2018 21:59:06 +0000 (21:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191478

Reviewed by Devin Rousso.

* UserInterface/Protocol/Connection.js:
(InspectorBackend.Connection.prototype._dispatchResponse):
(InspectorBackend.Connection.prototype._dispatchEvent):
(InspectorBackend.Connection.prototype._sendMessageToBackend):
Call tracer log methods with the connection.

* UserInterface/Debug/CapturingProtocolTracer.js:
* UserInterface/Protocol/ProtocolTracer.js:
* UserInterface/Protocol/LoggingProtocolTracer.js:
(WI.LoggingProtocolTracer):
(WI.LoggingProtocolTracer.prototype.logFrontendException):
(WI.LoggingProtocolTracer.prototype.logFrontendRequest):
(WI.LoggingProtocolTracer.prototype.logWillHandleResponse):
(WI.LoggingProtocolTracer.prototype.logDidHandleResponse):
(WI.LoggingProtocolTracer.prototype.logDidHandleEvent):
Include the connection in log methods.

(WI.LoggingProtocolTracer.prototype.logProtocolError):
Removed, this is never called.

(WI.LoggingProtocolTracer.prototype._processEntry):
Include the target identifier in entry messages.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238197 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Debug/CapturingProtocolTracer.js
Source/WebInspectorUI/UserInterface/Protocol/Connection.js
Source/WebInspectorUI/UserInterface/Protocol/LoggingProtocolTracer.js
Source/WebInspectorUI/UserInterface/Protocol/ProtocolTracer.js

index 266405e..3e361b4 100644 (file)
@@ -1,5 +1,35 @@
 2018-11-14  Joseph Pecoraro  <pecoraro@apple.com>
 
+        Web Inspector: Include target identifier in protocol logging
+        https://bugs.webkit.org/show_bug.cgi?id=191478
+
+        Reviewed by Devin Rousso.
+
+        * UserInterface/Protocol/Connection.js:
+        (InspectorBackend.Connection.prototype._dispatchResponse):
+        (InspectorBackend.Connection.prototype._dispatchEvent):
+        (InspectorBackend.Connection.prototype._sendMessageToBackend):
+        Call tracer log methods with the connection.
+
+        * UserInterface/Debug/CapturingProtocolTracer.js:
+        * UserInterface/Protocol/ProtocolTracer.js:
+        * UserInterface/Protocol/LoggingProtocolTracer.js:
+        (WI.LoggingProtocolTracer):
+        (WI.LoggingProtocolTracer.prototype.logFrontendException):
+        (WI.LoggingProtocolTracer.prototype.logFrontendRequest):
+        (WI.LoggingProtocolTracer.prototype.logWillHandleResponse):
+        (WI.LoggingProtocolTracer.prototype.logDidHandleResponse):
+        (WI.LoggingProtocolTracer.prototype.logDidHandleEvent):
+        Include the connection in log methods.
+
+        (WI.LoggingProtocolTracer.prototype.logProtocolError):
+        Removed, this is never called.
+                
+        (WI.LoggingProtocolTracer.prototype._processEntry):
+        Include the target identifier in entry messages.
+
+2018-11-14  Joseph Pecoraro  <pecoraro@apple.com>
+
         Web Inspector: Keep Web Inspector window alive across process swaps (PSON) (Remote Inspector)
         https://bugs.webkit.org/show_bug.cgi?id=191494
         <rdar://problem/45469854>
index d747186..552f8f1 100644 (file)
@@ -39,22 +39,17 @@ WI.CapturingProtocolTracer = class CapturingProtocolTracer extends WI.ProtocolTr
         return this._trace;
     }
 
-    logFrontendException(message, exception)
+    logFrontendException(connection, message, exception)
     {
         this._processEntry({type: "exception", message: this._stringifyMessage(message), exception});
     }
 
-    logProtocolError(message, error)
-    {
-        this._processEntry({type: "error", message: this._stringifyMessage(message), error});
-    }
-
-    logFrontendRequest(message)
+    logFrontendRequest(connection, message)
     {
         this._processEntry({type: "request", message: this._stringifyMessage(message)});
     }
 
-    logDidHandleResponse(message, timings = null)
+    logDidHandleResponse(connection, message, timings = null)
     {
         let entry = {type: "response", message: this._stringifyMessage(message)};
         if (timings)
@@ -63,7 +58,7 @@ WI.CapturingProtocolTracer = class CapturingProtocolTracer extends WI.ProtocolTr
         this._processEntry(entry);
     }
 
-    logDidHandleEvent(message, timings = null)
+    logDidHandleEvent(connection, message, timings = null)
     {
         let entry = {type: "event", message: this._stringifyMessage(message)};
         if (timings)
index 5b7e4cf..d5f607c 100644 (file)
@@ -108,7 +108,7 @@ InspectorBackend.Connection = class InspectorBackendConnection
 
         let processingStartTimestamp = performance.now();
         for (let tracer of InspectorBackend.activeTracers)
-            tracer.logWillHandleResponse(messageObject);
+            tracer.logWillHandleResponse(this, messageObject);
 
         InspectorBackend.currentDispatchState.request = request;
         InspectorBackend.currentDispatchState.response = messageObject;
@@ -127,7 +127,7 @@ InspectorBackend.Connection = class InspectorBackendConnection
         let roundTripTime = (processingStartTimestamp - responseData.sendRequestTimestamp).toFixed(3);
 
         for (let tracer of InspectorBackend.activeTracers)
-            tracer.logDidHandleResponse(messageObject, {rtt: roundTripTime, dispatch: processingTime});
+            tracer.logDidHandleResponse(this, messageObject, {rtt: roundTripTime, dispatch: processingTime});
 
         if (this._deferredScripts.length && !this._pendingResponses.size)
             this._flushPendingScripts();
@@ -186,7 +186,7 @@ InspectorBackend.Connection = class InspectorBackendConnection
 
         let processingStartTimestamp = performance.now();
         for (let tracer of InspectorBackend.activeTracers)
-            tracer.logWillHandleEvent(messageObject);
+            tracer.logWillHandleEvent(this, messageObject);
 
         InspectorBackend.currentDispatchState.event = messageObject;
 
@@ -194,7 +194,7 @@ InspectorBackend.Connection = class InspectorBackendConnection
             agent.dispatchEvent(eventName, eventArguments);
         } catch (e) {
             for (let tracer of InspectorBackend.activeTracers)
-                tracer.logFrontendException(messageObject, e);
+                tracer.logFrontendException(this, messageObject, e);
 
             WI.reportInternalError(e, {"cause": `An uncaught exception was thrown while handling event: ${qualifiedName}`});
         }
@@ -203,7 +203,7 @@ InspectorBackend.Connection = class InspectorBackendConnection
 
         let processingDuration = (performance.now() - processingStartTimestamp).toFixed(3);
         for (let tracer of InspectorBackend.activeTracers)
-            tracer.logDidHandleEvent(messageObject, {dispatch: processingDuration});
+            tracer.logDidHandleEvent(this, messageObject, {dispatch: processingDuration});
     }
 
     _sendCommandToBackendWithCallback(command, parameters, callback)
@@ -257,7 +257,7 @@ InspectorBackend.Connection = class InspectorBackendConnection
     _sendMessageToBackend(messageObject)
     {
         for (let tracer of InspectorBackend.activeTracers)
-            tracer.logFrontendRequest(messageObject);
+            tracer.logFrontendRequest(this, messageObject);
 
         this.sendMessageToBackend(JSON.stringify(messageObject));
     }
index 471fb36..6b8dbe4 100644 (file)
@@ -31,7 +31,7 @@ WI.LoggingProtocolTracer = class LoggingProtocolTracer extends WI.ProtocolTracer
 
         this._dumpMessagesToConsole = false;
         this._dumpTimingDataToConsole = false;
-        this._logToConsole = window.InspectorTest ? InspectorFrontendHost.unbufferedLog.bind(InspectorFrontendHost) : console.log.bind(console);
+        this._logToConsole = window.InspectorTest ? InspectorFrontendHost.unbufferedLog.bind(InspectorFrontendHost) : console.log;
     }
 
     // Public
@@ -56,45 +56,40 @@ WI.LoggingProtocolTracer = class LoggingProtocolTracer extends WI.ProtocolTracer
         return this._dumpTimingDataToConsole;
     }
 
-    logFrontendException(message, exception)
+    logFrontendException(connection, message, exception)
     {
-        this._processEntry({type: "exception", message, exception});
+        this._processEntry({type: "exception", connection, message, exception});
     }
 
-    logProtocolError(message, error)
+    logFrontendRequest(connection, message)
     {
-        this._processEntry({type: "error", message, error});
+        this._processEntry({type: "request", connection, message});
     }
 
-    logFrontendRequest(message)
+    logWillHandleResponse(connection, message)
     {
-        this._processEntry({type: "request", message});
-    }
-
-    logWillHandleResponse(message)
-    {
-        let entry = {type: "response", message};
+        let entry = {type: "response", connection, message};
         this._processEntry(entry);
     }
 
-    logDidHandleResponse(message, timings = null)
+    logDidHandleResponse(connection, message, timings = null)
     {
-        let entry = {type: "response", message};
+        let entry = {type: "response", connection, message};
         if (timings)
             entry.timings = Object.shallowCopy(timings);
 
         this._processEntry(entry);
     }
 
-    logWillHandleEvent(message)
+    logWillHandleEvent(connection, message)
     {
-        let entry = {type: "event", message};
+        let entry = {type: "event", connection, message};
         this._processEntry(entry);
     }
 
-    logDidHandleEvent(message, timings = null)
+    logDidHandleEvent(connection, message, timings = null)
     {
-        let entry = {type: "event", message};
+        let entry = {type: "event", connection, message};
         if (timings)
             entry.timings = Object.shallowCopy(timings);
 
@@ -109,7 +104,9 @@ WI.LoggingProtocolTracer = class LoggingProtocolTracer extends WI.ProtocolTracer
             else if (entry.timings.dispatch)
                 this._logToConsole(`time-stats: Handling: ${entry.timings.dispatch || NaN}ms`);
         } else if (this._dumpMessagesToConsole && !entry.timings) {
-            this._logToConsole(`${entry.type}: ${JSON.stringify(entry.message)}`);
+            let connection = entry.connection;
+            let targetId = connection && connection.target ? connection.target.identifier : "unknown";
+            this._logToConsole(`${entry.type} (${targetId}): ${JSON.stringify(entry.message)}`);
             if (entry.exception) {
                 this._logToConsole(entry.exception);
                 if (entry.exception.stack)
index d8f8600..dfbd232 100644 (file)
@@ -32,37 +32,32 @@ WI.ProtocolTracer = class ProtocolTracer
         // To be overridden by subclasses.
     }
 
-    logFrontendException(message, exception)
+    logFrontendException(connection, message, exception)
     {
         // To be overridden by subclasses.
     }
 
-    logProtocolError(message, error)
+    logFrontendRequest(connection, message)
     {
         // To be overridden by subclasses.
     }
 
-    logFrontendRequest(message)
+    logWillHandleResponse(connection, message)
     {
         // To be overridden by subclasses.
     }
 
-    logWillHandleResponse(message)
+    logDidHandleResponse(connection, message, timings = null)
     {
         // To be overridden by subclasses.
     }
 
-    logDidHandleResponse(message, timings = null)
+    logWillHandleEvent(connection, message)
     {
         // To be overridden by subclasses.
     }
 
-    logWillHandleEvent(message)
-    {
-        // To be overridden by subclasses.
-    }
-
-    logDidHandleEvent(message, timings = null)
+    logDidHandleEvent(connection, message, timings = null)
     {
         // To be overridden by subclasses.
     }