-
|
Hi, first I want to say to the maintainers/owner thank you so much for this crate, its been amazing for me!! Forgive me for a bit of a nube question- I'm new to flutter. I noticed that when I use the " flutter_rust_bridge::setup_default_user_utils() " method, that even though I don't have the log feature enabled, the log macro still works/is being initialized immediately. I assume this is a behavior coming from flutter_rust_bridge right now, it got late last night and I forgot to look to see if there was any kind of prefix when it was initialized! From what I've found on the rust side, I'm not exactly sure why the flutter_rust_bridge::setup_default_user_utils() function is initializing the log crate, since it appears anything that does that is gated behind the log feature. I also noticed looking at "setup_backtrace()" which is called in the above function, that if there is no RUST_BACKTRACE environment variable set, the above function seems to set it to 1, even in production. I'm not entirely sure why that's happening, and I'm not positive that, that even make sense- since usually this must happen before the program is executed. I also don't know how successful I would be in answering that question myself!! I'll be playing around with this some more at home to figure out if log is somehow being initialized elsewhere, but I was curious if anyone knew about this behavior! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
I just got home and checked it out, and it does seem to be that function "setup_default_user_utils()". I'm not entirely sure why it is causing log always to be initialized on my machine, even with the log feature not enabled. I'm a bit skeptical it has anything to do with this code, and am slightly more concerned than I was this morning pub fn setup_default_user_utils() {
// setup log before others, such that we can see logs in other setup functions
#[cfg(feature = "log")]
setup_log_to_console();
setup_backtrace();
}
fn setup_backtrace() {
#[cfg(not(target_family = "wasm"))]
if std::env::var("RUST_BACKTRACE").err() == Some(std::env::VarError::NotPresent) {
std::env::set_var("RUST_BACKTRACE", "1");
} else {
#[cfg(feature = "log")]
log::debug!("Skip setup RUST_BACKTRACE because there is already environment variable");
}
PanicBacktrace::setup();
}
#[cfg(feature = "log")]
fn setup_log_to_console() {
#[cfg(target_os = "android")]
let _ = android_logger::init_once(
android_logger::Config::default().with_max_level(log::LevelFilter::Trace),
);
#[cfg(any(target_os = "ios", target_os = "macos"))]
let _ = oslog::OsLogger::new("frb_user")
.level_filter(log::LevelFilter::Trace)
.init();
#[cfg(target_family = "wasm")]
let _ = crate::misc::web_utils::WebConsoleLogger::init();
} |
Beta Was this translation helpful? Give feedback.
-
|
Ah yep that explains it, I totally spaced on looking at that. Thanks for
replying, I was thinking it was okay not to use, but didn't want to find out it wasn't
later for some reason with the whole backtrace/panic backtrace thing!!
…On Fri, Dec 5, 2025 at 7:19 AM fzyzcjy ***@***.***> wrote:
I guess maybe the log feature is by default enabled.
https://github.com/fzyzcjy/flutter_rust_bridge/blob/468953fff6dc74355c49daa79453ab379c90992a/frb_rust/Cargo.toml#L70.
Also, since it says setup "default" utils, feel free to remove the function
call or change to anything you like if the default thing does not fit your
usage!
—
Reply to this email directly, view it on GitHub
<#2944 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BDLIHGPULESQWHHJC3PIO5L4AFZ4TAVCNFSM6AAAAACN6MVBE6VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTKMJXGE4DEOA>
.
You are receiving this because you authored the thread.Message ID:
<fzyzcjy/flutter_rust_bridge/repo-discussions/2944/comments/15171828@
github.com>
|
Beta Was this translation helpful? Give feedback.
I guess maybe the log feature is by default enabled.
flutter_rust_bridge/frb_rust/Cargo.toml
Line 70 in 468953f