ASSIGNED 176106
Add Logger observer and helper class
https://bugs.webkit.org/show_bug.cgi?id=176106
Summary Add Logger observer and helper class
Eric Carlson
Reported 2017-08-30 08:33:36 PDT
Make it possible to observe Logger output. Add a helper class to make logging code less verbose.
Attachments
Proposed patch. (15.07 KB, patch)
2017-08-30 08:57 PDT, Eric Carlson
no flags
Proposed patch. (15.07 KB, patch)
2017-08-30 09:23 PDT, Eric Carlson
no flags
Patch for landing (15.37 KB, patch)
2017-08-30 11:26 PDT, Eric Carlson
no flags
Eric Carlson
Comment 1 2017-08-30 08:57:09 PDT
Created attachment 319367 [details] Proposed patch.
Build Bot
Comment 2 2017-08-30 08:58:28 PDT
Attachment 319367 [details] did not pass style-queue: ERROR: Source/WebCore/PAL/pal/Logger.h:59: The parameter name "channel" adds no information, so it should be removed. [readability/parameter_name] [5] Total errors found: 1 in 4 files If any of these errors are false positives, please file a bug against check-webkit-style.
Eric Carlson
Comment 3 2017-08-30 09:23:44 PDT
Created attachment 319370 [details] Proposed patch.
Andy Estes
Comment 4 2017-08-30 09:44:42 PDT
Comment on attachment 319370 [details] Proposed patch. View in context: https://bugs.webkit.org/attachment.cgi?id=319370&action=review > Source/WebCore/PAL/pal/Logger.h:40 > + template<typename U = T> static typename std::enable_if<std::is_same<U, bool>::value, String>::type toString(bool argument) { return argument ? String("true") : String("false"); } You can use ASCIILiteral for "true" and "false". > Source/WebCore/PAL/pal/Logger.h:45 > + template<typename U = T> static typename std::enable_if<std::is_same<U, AtomicString>::value, String>::type toString(AtomicString argument) { return argument.string(); } > + template<typename U = T> static typename std::enable_if<std::is_same<U, const AtomicString&>::value, String>::type toString(const AtomicString& argument) { return argument.string(); } I wonder if you can use typename std::remove_reference<U>::type in the std::is_same<> check so that you don't have to treat AtomicString and const AtomicString& separately. > Source/WebCore/PAL/pal/Logger.h:47 > + template<typename U = T> static typename std::enable_if<std::is_same<U, const String&>::value, String>::type toString(const String& argument) { return argument; } Ditto. > Source/WebCore/PAL/pal/Logger.h:169 > + static inline void removeObserver(Observer& observer) Looks like it's up to the caller to ensure that removeObserver() is called before an Observer passed to addObserver() is destroyed. Is that the design?
Eric Carlson
Comment 5 2017-08-30 11:20:11 PDT
Comment on attachment 319370 [details] Proposed patch. View in context: https://bugs.webkit.org/attachment.cgi?id=319370&action=review Thanks! >> Source/WebCore/PAL/pal/Logger.h:40 >> + template<typename U = T> static typename std::enable_if<std::is_same<U, bool>::value, String>::type toString(bool argument) { return argument ? String("true") : String("false"); } > > You can use ASCIILiteral for "true" and "false". Fixed. >> Source/WebCore/PAL/pal/Logger.h:45 >> + template<typename U = T> static typename std::enable_if<std::is_same<U, const AtomicString&>::value, String>::type toString(const AtomicString& argument) { return argument.string(); } > > I wonder if you can use typename std::remove_reference<U>::type in the std::is_same<> check so that you don't have to treat AtomicString and const AtomicString& separately. Great idea, fixed. >> Source/WebCore/PAL/pal/Logger.h:47 >> + template<typename U = T> static typename std::enable_if<std::is_same<U, const String&>::value, String>::type toString(const String& argument) { return argument; } > > Ditto. Ditto. >> Source/WebCore/PAL/pal/Logger.h:169 >> + static inline void removeObserver(Observer& observer) > > Looks like it's up to the caller to ensure that removeObserver() is called before an Observer passed to addObserver() is destroyed. Is that the design? Yes, I wanted to keep this as simple as possible for now. I will reevaluate later when it is used outside of testing.
Eric Carlson
Comment 6 2017-08-30 11:26:12 PDT
Created attachment 319382 [details] Patch for landing
WebKit Commit Bot
Comment 7 2017-08-30 12:06:53 PDT
Comment on attachment 319382 [details] Patch for landing Clearing flags on attachment: 319382 Committed r221388: <http://trac.webkit.org/changeset/221388>
Radar WebKit Bug Importer
Comment 8 2017-08-30 12:11:08 PDT
Note You need to log in before you can comment on or make changes to this bug.