Skip to content

[WPE] Log messages to the Android log where appropriate #47339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aperezdc
Copy link
Contributor

@aperezdc aperezdc commented Jun 28, 2025

284b9dc

[WPE] Log messages to the Android log where appropriate
https://bugs.webkit.org/show_bug.cgi?id=295155

Reviewed by NOBODY (OOPS!).

Add an Android-specific version of the logging macros. Those use
__android_log_print() to get the messages sent to the system log
facility. LogChannel is also augmented with calls to the Android
logging functions where appropriate.

Also, on actual devices Android closes the standard error stream of
processes by default, therefore it is handy to have messages send to
the standard error stream forwarded to the system log.

In all cases, the name of the LogChannel subsystem is set as the
Android logging tag, which means that the corresponding system
property (i.e. "log.tag.<name>") needs to be set in order for logs
to be sent to the system log. This can be achieved for example with
the following command using ADB:

  adb shell setprop log.tag.WPEWebKit VERBOSE

Or, to save the setting:

  adb shell setprop persist.log.tag.WPEWebKit VERBOSE

The logging level may be set to VERBOSE, DEBUG, INFO, WARN, ERROR,
or FATAL. Those correspond to the log levels defined in <android/log.h>.
More information about how to configure the logger can be found at:

  https://android.googlesource.com/platform/system/core/+/66607ebc0e451/logd/README.property

Setting environment variables on Android is a bit of a chore, so in
the future it may be desirable to read the list of enabled logging
channels from a system property instead.

91c5647

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ⏳ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
loading 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🛠 🧪 jsc ✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 🧪 jsc-arm64 ✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2 ✅ 🛠 playstation
✅ 🛠 tv ✅ 🛠 mac-safer-cpp ✅ 🛠 jsc-armv7
✅ 🛠 tv-sim ❌ 🧪 jsc-armv7-tests
✅ 🛠 watch
✅ 🛠 watch-sim

@aperezdc aperezdc requested review from a team as code owners June 28, 2025 15:54
@aperezdc aperezdc self-assigned this Jun 28, 2025
@aperezdc aperezdc added the WPE WebKit WebKit WPE component label Jun 28, 2025
@aperezdc
Copy link
Contributor Author

Combining this with #47352 makes it much easier to configure which logging channels to enable on Android.

Copy link
Contributor

@spenap spenap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good, this will be very useful 👍 !

@aperezdc
Copy link
Contributor Author

aperezdc commented Jul 1, 2025

This will need a rebase now that #47375 has landed.

https://bugs.webkit.org/show_bug.cgi?id=295155

Reviewed by NOBODY (OOPS!).

Add an Android-specific version of the logging macros. Those use
__android_log_print() to get the messages sent to the system log
facility. LogChannel is also augmented with calls to the Android
logging functions where appropriate.

Also, on actual devices Android closes the standard error stream of
processes by default, therefore it is handy to have messages send to
the standard error stream forwarded to the system log.

In all cases, the name of the LogChannel subsystem is set as the
Android logging tag, which means that the corresponding system
property (i.e. "log.tag.<name>") needs to be set in order for logs
to be sent to the system log. This can be achieved for example with
the following command using ADB:

  adb shell setprop log.tag.WPEWebKit VERBOSE

Or, to save the setting:

  adb shell setprop persist.log.tag.WPEWebKit VERBOSE

The logging level may be set to VERBOSE, DEBUG, INFO, WARN, ERROR,
or FATAL. Those correspond to the log levels defined in <android/log.h>.
More information about how to configure the logger can be found at:

  https://android.googlesource.com/platform/system/core/+/66607ebc0e451/logd/README.property

Setting environment variables on Android is a bit of a chore, so in
the future it may be desirable to read the list of enabled logging
channels from a system property instead.

* Source/JavaScriptCore/jsc.cpp:
(main):
* Source/WTF/wtf/Assertions.cpp:
* Source/WTF/wtf/Assertions.h:
* Source/WTF/wtf/Logger.h:
(WTF::Logger::willLog const):
(WTF::Logger::log):
(WTF::Logger::logVerbose):
* Source/WTF/wtf/PlatformWPE.cmake:
* Source/WTF/wtf/WTFConfig.h:
* Source/cmake/FindAndroid.cmake: Added.
* Source/cmake/OptionsWPE.cmake:
@aperezdc
Copy link
Contributor Author

aperezdc commented Jul 1, 2025

This will need a rebase now that #47375 has landed.

Done. Also fixed a couple of instances where WTFLogChannel::name was being used as the log tag, and now all the call sites use LOG_CHANNEL_WEBKIT_SUBSYSTEM as it has always been intended.

Please take a look, this should be good to go now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WPE WebKit WebKit WPE component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants