notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 5f21d32d9674a241a550d1cb326d8e88f0e70304
parent fe6206c5463a5d5f5dbbca3900642cc3e7ca6ec4
Author: William Casarin <jb55@jb55.com>
Date:   Sat,  4 Jan 2025 13:13:34 -0800

android: fix android logging

Diffstat:
MCargo.lock | 62++++++++++++--------------------------------------------------
MCargo.toml | 1-
Mcrates/notedeck_chrome/Cargo.toml | 2+-
Mcrates/notedeck_chrome/src/android.rs | 25++++++++++++++++++++++++-
Mcrates/notedeck_columns/Cargo.toml | 1-
5 files changed, 37 insertions(+), 54 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -134,24 +134,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" [[package]] -name = "android_log-sys" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85965b6739a430150bdd138e2374a98af0c3ee0d030b3bb7fc3bddff58d0102e" - -[[package]] -name = "android_logger" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8619b80c242aa7bd638b5c7ddd952addeecb71f69c75e33f1d47b2804f8f883a" -dependencies = [ - "android_log-sys", - "env_logger", - "log", - "once_cell", -] - -[[package]] name = "android_system_properties" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1256,19 +1238,6 @@ dependencies = [ ] [[package]] -name = "env_logger" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" -dependencies = [ - "humantime", - "is-terminal", - "log", - "regex", - "termcolor", -] - -[[package]] name = "epaint" version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1790,12 +1759,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - -[[package]] name = "icu_collections" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2033,17 +1996,6 @@ dependencies = [ ] [[package]] -name = "is-terminal" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys 0.52.0", -] - -[[package]] name = "is-wsl" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2566,7 +2518,6 @@ name = "notedeck_chrome" version = "0.2.0" dependencies = [ "android-activity 0.4.3", - "android_logger", "eframe", "egui", "egui_extras", @@ -2583,6 +2534,7 @@ dependencies = [ "tokio", "tracing", "tracing-appender", + "tracing-logcat", "tracing-subscriber", "winit", ] @@ -2601,7 +2553,6 @@ dependencies = [ "egui_virtual_list", "ehttp 0.2.0", "enostr", - "env_logger", "hex", "image", "indexmap", @@ -4355,6 +4306,17 @@ dependencies = [ ] [[package]] +name = "tracing-logcat" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678d561ce3d4b33dfcfb1c6bd13c422aad89be5bf0e66e20d518a5a254345b54" +dependencies = [ + "rustix", + "tracing", + "tracing-subscriber", +] + +[[package]] name = "tracing-subscriber" version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/Cargo.toml b/Cargo.toml @@ -21,7 +21,6 @@ egui_tabs = "0.2.0" egui_virtual_list = "0.5.0" ehttp = "0.2.0" enostr = { path = "crates/enostr" } -env_logger = "0.10.0" ewebsock = { version = "0.2.0", features = ["tls"] } hex = "0.4.3" image = { version = "0.25", features = ["jpeg", "png", "webp"] } diff --git a/crates/notedeck_chrome/Cargo.toml b/crates/notedeck_chrome/Cargo.toml @@ -44,7 +44,7 @@ default = [] profiling = ["notedeck_columns/puffin", "puffin", "puffin_egui"] [target.'cfg(target_os = "android")'.dependencies] -android_logger = "0.11.1" +tracing-logcat = "0.1.0" log = { workspace = true } android-activity = { version = "0.4", features = [ "native-activity" ] } winit = { version = "0.30.5", features = [ "android-native-activity" ] } diff --git a/crates/notedeck_chrome/src/android.rs b/crates/notedeck_chrome/src/android.rs @@ -9,8 +9,31 @@ use winit::platform::android::EventLoopBuilderExtAndroid; #[no_mangle] #[tokio::main] pub async fn android_main(app: AndroidApp) { + use tracing_logcat::{LogcatMakeWriter, LogcatTag}; + use tracing_subscriber::{prelude::*, EnvFilter}; + std::env::set_var("RUST_BACKTRACE", "full"); - android_logger::init_once(android_logger::Config::default().with_min_level(log::Level::Info)); + std::env::set_var( + "RUST_LOG", + "enostr=debug,notedeck_columns=debug,notedeck_chrome=debug", + ); + + let writer = + LogcatMakeWriter::new(LogcatTag::Target).expect("Failed to initialize logcat writer"); + + let fmt_layer = tracing_subscriber::fmt::layer() + .with_level(false) + .with_target(false) + .without_time(); + + let filter_layer = EnvFilter::try_from_default_env() + .or_else(|_| EnvFilter::try_new("info")) + .unwrap(); + + tracing_subscriber::registry() + .with(filter_layer) + .with(fmt_layer) + .init(); let path = app.internal_data_path().expect("data path"); let mut options = eframe::NativeOptions::default(); diff --git a/crates/notedeck_columns/Cargo.toml b/crates/notedeck_columns/Cargo.toml @@ -23,7 +23,6 @@ egui_tabs = { workspace = true } egui_virtual_list = { workspace = true } ehttp = { workspace = true } enostr = { workspace = true } -env_logger = { workspace = true } hex = { workspace = true } image = { workspace = true } indexmap = { workspace = true }