RESOLVED FIXED 28047
add utility method to enable logging messages for inspector development
https://bugs.webkit.org/show_bug.cgi?id=28047
Summary add utility method to enable logging messages for inspector development
Patrick Mueller
Reported 2009-08-06 08:53:19 PDT
It's handy to have somewhere to dump messages while doing Web Inspector development. The existing console seems like a handy place. Unfortunately, the code to get a message added to the console is non-trivial, as it requires building a ConsoleMessage object first. Suggestion is to add a utility method to ConsoleView called "log" which can be called from within Web Inspector code to easily log messages to the console. Code can then just use something like the following to dump a message: WebInspector.console.log("Hello, world!"); Additional suggestion that the message be styled somehow to differentiate it from other messages in the console.
Attachments
patch to ConsoleView to add a log() function (2.58 KB, patch)
2009-08-06 08:55 PDT, Patrick Mueller
no flags
proposed patch (3.52 KB, patch)
2009-08-10 11:11 PDT, Patrick Mueller
timothy: review-
proposed patch - 2009/08/31 (6.41 KB, patch)
2009-08-31 15:54 PDT, Patrick Mueller
no flags
Patrick Mueller
Comment 1 2009-08-06 08:55:42 PDT
Created attachment 34211 [details] patch to ConsoleView to add a log() function Uploading patch to see if this seems appropriate. the "log" method on ConsoleView instances will append a message of a new message level "Debug". These messages are styled with the "search" icon to distinguish them from other messages in the console.
Anthony Ricaud
Comment 2 2009-08-08 05:03:50 PDT
You can already log messages with the traditional console api. Messages will appear in the inspector's inspector. Open it with the Inspect Element contextual option on any part o thé inspector. This is far more useful since you can use the whole console api.
Patrick Mueller
Comment 3 2009-08-08 15:19:58 PDT
Yes, I understand. But if all I need is a "printf" capability, bringing up inspector gets in the way. It's also not clear that all environments support "inspecting the inspector". Since doing the patch, I figured it would be even easier to have a log function directly off of "WebInspector" instead of having to traverse through the console object.
Patrick Mueller
Comment 4 2009-08-10 11:06:07 PDT
changed title to remove specific implementation detail
Patrick Mueller
Comment 5 2009-08-10 11:11:23 PDT
Created attachment 34485 [details] proposed patch New patch adds a method "log" to the WebInspector global which takes a string and prints it to the existing console, using a "magnifying glass" icon to distinguish it from other console messages. Intended to be used while developing Web Inspector code, so you can easily print a message to the console that's already available.
Timothy Hatcher
Comment 6 2009-08-27 08:32:35 PDT
Comment on attachment 34485 [details] proposed patch WebCore/page/Console.h needs updated to match the MessageLevel change. (Even if there is no C++ use of Debug.) Otherwise this seems fine.
Patrick Mueller
Comment 7 2009-08-31 15:54:48 PDT
Created attachment 38841 [details] proposed patch - 2009/08/31 Per previous review, updated WebCore/page/Console.h with the new level. Also added corresponding change in the .cpp file (to print the level name). I also attempted to get the "repeatCount" bit right with the message. As it is, if you repeat a message, as in the supplied manual test case, you get neither a new message nor a repeat count badge. I'm going to chalk this up to wonkiness introduced by bug 28856, but I don't think the bad behaviour is a show-stopper, since the new behaviour is only relevant to WebKit developers. I've tested the repeatCount code by manually maintaining a repeatCount myself, just to make sure the CSS bits work, and they do. What I don't know is if I have to actually maintain the repeatCount, or if the ConsoleView.addMessage() is supposed to be doing that for me. Looks like the latter.
Eric Seidel (no email)
Comment 8 2009-09-01 17:38:16 PDT
Comment on attachment 38841 [details] proposed patch - 2009/08/31 Clearing flags on attachment: 38841 Committed r47952: <http://trac.webkit.org/changeset/47952>
Eric Seidel (no email)
Comment 9 2009-09-01 17:38:19 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.