You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Redirect console output to logcat on Android #19999
The console output (components/script/dom/console.rs) is always sent to stdout. On Android, it should go to the logcat by using the android log service. Using the standard log macros does the right thing so it's an easy change.
What I'd like to get clarification on is how to organize this kind of platform dependent implementation. Should I:
Pepper the current console.rs with cfg(target_os = "android")] blocks.
Put the android implementation in dom/console_android.rs and select this file in dom/mod.rs.
Put the android implementation in dom/android/console.rs and select this module in dom/mod.rs.
I'm a little bit confused, as Servo on Android has redirected all stdout/stderr to Android logcat automatically ever since I first did the port. Did that change? We basically just spun up a background thread that redirected the handles.
In any case, we traditionally had just redirected all the random goop that goes to console to the android log, assuming that we'd be unable to get the myriad Rust dependencies to all unify their output to Rust logging components and redirect that to the android log facilities.
Ha, that's because my device is android-but-not-really, and so it's not using the redirection provided by the android glue.
The standard log macros, when used with eg the android_logger crate do the right thing like setting the log level in the android subsystem so you can filter them properly. Actually most of Servo debug info ends up in logcat this way, just not the console logs.
So improving the situation for console.log() would not change anything the android glue redirect of stdout, but would still be an improvement.
When #20912 lands, I think the right approach will be to delegate console printing to the embedder, the same way it's done for window.alert, and in the case of android, write to logcat via android_logger (see the change in the alert code in the PR).
Activity
larsbergstrom commentedon Feb 8, 2018
I'm a little bit confused, as Servo on Android has redirected all stdout/stderr to Android logcat automatically ever since I first did the port. Did that change? We basically just spun up a background thread that redirected the handles.
I think android_rs_glue has something similar, though rust-mobile/android-rs-glue@72be8df may no longer be relevant?
In any case, we traditionally had just redirected all the random goop that goes to console to the android log, assuming that we'd be unable to get the myriad Rust dependencies to all unify their output to Rust logging components and redirect that to the android log facilities.
cc @paulrouget
fabricedesre commentedon Feb 8, 2018
Ha, that's because my device is android-but-not-really, and so it's not using the redirection provided by the android glue.
The standard log macros, when used with eg the android_logger crate do the right thing like setting the log level in the android subsystem so you can filter them properly. Actually most of Servo debug info ends up in logcat this way, just not the console logs.
So improving the situation for console.log() would not change anything the android glue redirect of stdout, but would still be an improvement.
paulrouget commentedon Jul 31, 2018
When #20912 lands, I think the right approach will be to delegate console printing to the embedder, the same way it's done for
window.alert, and in the case of android, write to logcat via android_logger (see the change in the alert code in the PR).