ohos/android: Redirect stdout/stderr to log sink (#32858)

* ohos: redirect stdout/stderr to logging sink

Based on the existing android `redirect_stdout_to_logcat` implementation,
but using the safe abstractions from `nix` and dumping to the `log` sink,
instead of directly writing the log.

Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>

* android: Use new shared implementation for logcat redirection.

Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>

* servoshell: Register cfg(production)

Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>

* Update ports/servoshell/egl/log.rs

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Signed-off-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com>

* Change info! to debug! to match original behavior on android

Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>

---------

Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>
Signed-off-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Jonathan Schwender 2024-08-15 17:26:03 +08:00 committed by GitHub
parent 353ceb0ffb
commit 97c84b6127
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 127 additions and 93 deletions

View file

@ -66,9 +66,6 @@ android_logger = "0.14"
ipc-channel = { workspace = true }
jni = "0.21.1"
libloading = "0.8"
serde_json = { workspace = true }
surfman = { workspace = true, features = ["sm-angle-default"] }
webxr = { git = "https://github.com/servo/webxr" }
[target.'cfg(not(target_os = "android"))'.dependencies]
@ -82,11 +79,14 @@ ipc-channel = { workspace = true, features = ["force-inprocess"] }
hilog = "0.1.0"
napi-derive-ohos = "0.0.9"
napi-ohos = "0.1"
serde_json = { workspace = true }
surfman = { workspace = true, features = ["sm-angle-default"] }
webxr = { git = "https://github.com/servo/webxr" }
ohos-sys = { version = "0.2.1", features = ["xcomponent"] }
[target.'cfg(any(target_os = "android", target_env = "ohos"))'.dependencies]
nix = { workspace = true, features = ["fs"] }
surfman = { workspace = true, features = ["sm-angle-default"] }
serde_json = { workspace = true }
webxr = { git = "https://github.com/servo/webxr" }
[target.'cfg(not(any(target_os = "android", target_env = "ohos")))'.dependencies]
# For optional feature servo_allocator/use-system-allocator
@ -117,3 +117,6 @@ sig = "1.0"
webxr = { git = "https://github.com/servo/webxr", features = ["ipc", "glwindow", "headless", "openxr-api"] }
windows-sys = { workspace = true, features = ["Win32_Graphics_Gdi"] }
libservo = { path = "../../components/servo", features = ["no-wgl"] }
[lints.rust]
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(production)'] }