Bug 228768 - Support WTF logging channels
Summary: Support WTF logging channels
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Myles C. Maxfield
URL:
Keywords: InRadar
Depends on: 228809
Blocks: 228764
  Show dependency treegraph
 
Reported: 2021-08-04 02:14 PDT by Myles C. Maxfield
Modified: 2021-08-09 20:10 PDT (History)
14 users (show)

See Also:


Attachments
Patch (47.98 KB, patch)
2021-08-04 02:23 PDT, Myles C. Maxfield
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (48.04 KB, patch)
2021-08-04 02:31 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (47.93 KB, patch)
2021-08-07 02:14 PDT, Myles C. Maxfield
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (47.99 KB, patch)
2021-08-07 02:22 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (47.84 KB, patch)
2021-08-07 02:24 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (47.62 KB, patch)
2021-08-08 19:28 PDT, Myles C. Maxfield
Hironori.Fujii: review+
Hironori.Fujii: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Myles C. Maxfield 2021-08-04 02:14:54 PDT
Support WTF logging channels
Comment 1 Myles C. Maxfield 2021-08-04 02:23:11 PDT
Created attachment 434895 [details]
Patch
Comment 2 Myles C. Maxfield 2021-08-04 02:31:01 PDT
Created attachment 434896 [details]
Patch
Comment 3 Simon Fraser (smfr) 2021-08-04 10:21:44 PDT
Comment on attachment 434896 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=434896&action=review

r- to remove code duplicated between WTF, WebCore and WebKit.

> Source/WTF/wtf/Logging.h:57
> +WTF_EXPORT_PRIVATE String logLevelString();
> +bool isLogChannelEnabled(const String& name);
> +WTF_EXPORT_PRIVATE void setLogChannelToAccumulate(const String& name);
> +WTF_EXPORT_PRIVATE void clearAllLogChannelsToAccumulate();
> +WTF_EXPORT_PRIVATE void initializeLogChannelsIfNecessary(std::optional<String> = std::nullopt);

I think you should follow WebCore and put these in LogInitialization.h (there was a reason I split things into two headers, but I forget what it was).

I think you can also remove the WebCore and WebKit implementations of these functions, sharing all the code from WTF.
Comment 4 Myles C. Maxfield 2021-08-07 02:14:10 PDT
Created attachment 435121 [details]
Patch
Comment 5 Myles C. Maxfield 2021-08-07 02:22:23 PDT
Created attachment 435122 [details]
Patch
Comment 6 Myles C. Maxfield 2021-08-07 02:24:42 PDT
Created attachment 435123 [details]
Patch
Comment 7 Fujii Hironori 2021-08-07 05:15:30 PDT
You might want to update the documentation. https://github.com/WebKit/WebKit/blob/main/Introduction.md#logging-in-webkit
Comment 8 Myles C. Maxfield 2021-08-07 11:18:34 PDT
(In reply to Fujii Hironori from comment #7)
> You might want to update the documentation.
> https://github.com/WebKit/WebKit/blob/main/Introduction.md#logging-in-webkit

Yeah, good idea. It looks like nothing that's currently written there is inaccurate with these latest patches, but I can add some more details which will make it more clear how to do things like enable/disable log channels.
Comment 9 Myles C. Maxfield 2021-08-07 11:20:12 PDT
Also, I can add information about how to add a new log channel, which macro to use where, etc.
Comment 10 Myles C. Maxfield 2021-08-07 12:31:46 PDT
https://bugs.webkit.org/show_bug.cgi?id=228899
Comment 11 Fujii Hironori 2021-08-08 05:43:04 PDT
Comment on attachment 435123 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=435123&action=review

> Source/WTF/wtf/MemoryPressureHandler.cpp:56
> +#endif

Do you still need to explicitly call WTFInitializeLogChannelStatesFromString for MemoryPressure log channel?
I think WTF::logChannels().initializeLogChannelsIfNecessary() does the initialization even for MemoryPressure log channel.

> Source/WTF/wtf/unix/LoggingUnix.cpp:38
> +        return makeString("-all"_s);

This seems unexpected behavior change. This disable all WTF log channels as default if WEBKIT_DEBUG is not set.

> Source/WTF/wtf/unix/LoggingUnix.cpp:46
> +    return makeString("NotYetImplemented,"_s, logEnv);

This seems useless. WTF module doesn't have "NotYetImplemented" log channel.
Comment 12 Myles C. Maxfield 2021-08-08 19:27:34 PDT
Comment on attachment 435123 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=435123&action=review

>> Source/WTF/wtf/MemoryPressureHandler.cpp:56
>> +#endif
> 
> Do you still need to explicitly call WTFInitializeLogChannelStatesFromString for MemoryPressure log channel?
> I think WTF::logChannels().initializeLogChannelsIfNecessary() does the initialization even for MemoryPressure log channel.

Right! Good catch.

>> Source/WTF/wtf/unix/LoggingUnix.cpp:38
>> +        return makeString("-all"_s);
> 
> This seems unexpected behavior change. This disable all WTF log channels as default if WEBKIT_DEBUG is not set.

Right, yes. I copied this from WebCore, but you're right that I shouldn't be changing this behavior.

>> Source/WTF/wtf/unix/LoggingUnix.cpp:46
>> +    return makeString("NotYetImplemented,"_s, logEnv);
> 
> This seems useless. WTF module doesn't have "NotYetImplemented" log channel.

Right.
Comment 13 Myles C. Maxfield 2021-08-08 19:28:12 PDT
Created attachment 435163 [details]
Patch
Comment 14 Fujii Hironori 2021-08-08 20:37:25 PDT
Comment on attachment 435163 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=435163&action=review

LGTM

> Source/WTF/wtf/unix/LoggingUnix.cpp:41
> +    // To disable logging notImplemented set the DISABLE_NI_WARNING environment variable to 1.

Remove this comment.
Comment 15 Myles C. Maxfield 2021-08-09 14:15:05 PDT
Committed r280795 (240373@main): <https://commits.webkit.org/240373@main>
Comment 16 Radar WebKit Bug Importer 2021-08-09 14:41:36 PDT
<rdar://problem/81713600>
Comment 17 Fujii Hironori 2021-08-09 18:49:04 PDT
(In reply to Myles C. Maxfield from comment #15)
> Committed r280795 (240373@main): <https://commits.webkit.org/240373@main>

This change caused build failures for Debug builds of Win, GTK and WPE ports.

  Bug 228938 – [GTK][WPE] REGRESSION(r280795): MemoryPressureHandlerUnix.cpp:45:28: error: ‘LogMemoryPressure’ was not declared in this scope
  Bug 228937 – [WTF][Win] REGRESSION(r280795) error LNK2019: unresolved external symbol "class WTF::String __cdecl WTF::logLevelString(void)"
Comment 18 Myles C. Maxfield 2021-08-09 20:10:04 PDT
(In reply to Fujii Hironori from comment #17)
> (In reply to Myles C. Maxfield from comment #15)
> > Committed r280795 (240373@main): <https://commits.webkit.org/240373@main>
> 
> This change caused build failures for Debug builds of Win, GTK and WPE ports.
> 
>   Bug 228938 – [GTK][WPE] REGRESSION(r280795):
> MemoryPressureHandlerUnix.cpp:45:28: error: ‘LogMemoryPressure’ was not
> declared in this scope
>   Bug 228937 – [WTF][Win] REGRESSION(r280795) error LNK2019: unresolved
> external symbol "class WTF::String __cdecl WTF::logLevelString(void)"

Oh, no :(

EWS was green though :(

Thanks for fixing it!!!