Web Inspector: Protocol Logging: log messages as objects if inspector^2 is open
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Jan 2019 19:38:45 +0000 (19:38 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Jan 2019 19:38:45 +0000 (19:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193284

Reviewed by Joseph Pecoraro.

Source/WebCore:

No newe tests, as this is simply exposes a value.

* inspector/InspectorFrontendHost.idl:
* inspector/InspectorFrontendHost.h:
* inspector/InspectorFrontendHost.cpp:
(WebCore::InspectorFrontendHost::isBeingInspected): Added.

Source/WebInspectorUI:

If inspector^2 is closed, stringify all messages.
If inspector^2 is open, log each message JSON object without modifying it.

* UserInterface/Protocol/LoggingProtocolTracer.js:
(WI.LoggingProtocolTracer.prototype._processEntry):

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

Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorFrontendHost.cpp
Source/WebCore/inspector/InspectorFrontendHost.h
Source/WebCore/inspector/InspectorFrontendHost.idl
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Protocol/LoggingProtocolTracer.js

index 63394d7..c28dee6 100644 (file)
@@ -1,3 +1,17 @@
+2019-01-09  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Protocol Logging: log messages as objects if inspector^2 is open
+        https://bugs.webkit.org/show_bug.cgi?id=193284
+
+        Reviewed by Joseph Pecoraro.
+
+        No newe tests, as this is simply exposes a value.
+
+        * inspector/InspectorFrontendHost.idl:
+        * inspector/InspectorFrontendHost.h:
+        * inspector/InspectorFrontendHost.cpp:
+        (WebCore::InspectorFrontendHost::isBeingInspected): Added.
+
 2019-01-09  Zalan Bujtas  <zalan@apple.com>
 
         [LFC][BFC][MarginCollapsing] Add support for peculiar cases.
index c080a56..15b8dc0 100644 (file)
@@ -445,6 +445,15 @@ void InspectorFrontendHost::inspectInspector()
         m_frontendPage->inspectorController().show();
 }
 
+bool InspectorFrontendHost::isBeingInspected()
+{
+    if (!m_frontendPage)
+        return false;
+
+    InspectorController& inspectorController = m_frontendPage->inspectorController();
+    return inspectorController.hasLocalFrontend() || inspectorController.hasRemoteFrontend();
+}
+
 bool InspectorFrontendHost::supportsShowCertificate() const
 {
 #if PLATFORM(COCOA)
index 9c04425..5242cc6 100644 (file)
@@ -109,6 +109,7 @@ public:
 
     void beep();
     void inspectInspector();
+    bool isBeingInspected();
 
 private:
 #if ENABLE(CONTEXT_MENUS)
index 163274b..c7cbf9d 100644 (file)
@@ -81,6 +81,7 @@
 
     void beep();
     void inspectInspector();
+    boolean isBeingInspected();
 };
 
 dictionary ContextMenuItem {
index 6f13654..1015bff 100644 (file)
@@ -1,3 +1,16 @@
+2019-01-09  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Protocol Logging: log messages as objects if inspector^2 is open
+        https://bugs.webkit.org/show_bug.cgi?id=193284
+
+        Reviewed by Joseph Pecoraro.
+
+        If inspector^2 is closed, stringify all messages.
+        If inspector^2 is open, log each message JSON object without modifying it.
+
+        * UserInterface/Protocol/LoggingProtocolTracer.js:
+        (WI.LoggingProtocolTracer.prototype._processEntry):
+
 2019-01-09  Nikita Vasilyev  <nvasilyev@apple.com>
 
         Web Inspector: Styles: clicking on property that soon to be discarded shouldn't start selection
index 8d4390d..5009a30 100644 (file)
@@ -119,7 +119,13 @@ WI.LoggingProtocolTracer = class LoggingProtocolTracer extends WI.ProtocolTracer
             let targetId = connection && connection.target ? connection.target.identifier : "unknown";
             if (this._filterMultiplexingBackend && targetId === "multi")
                 return;
-            this._logToConsole(`${entry.type} (${targetId}): ${JSON.stringify(entry.message)}`);
+
+            let prefix = `${entry.type} (${targetId})`;
+            if (!window.InspectorTest && InspectorFrontendHost.isBeingInspected())
+                this._logToConsole(prefix, entry.message);
+            else
+                this._logToConsole(`${prefix}: ${JSON.stringify(entry.message)}`);
+
             if (entry.exception) {
                 this._logToConsole(entry.exception);
                 if (entry.exception.stack)