Closed zhpixel517 closed 3 months ago
@fzyzcjy is this related to https://github.com/fzyzcjy/flutter_rust_bridge/discussions/2240?
For extra context, this is my Cargo.toml:
[package]
name = "rust_lib_flutter_rust_test"
version = "0.1.0"
edition = "2021"
[lib]
crate-type = ["cdylib", "staticlib"]
[dependencies]
android_logger = "0.14.1"
cpal = "0.15.3"
opus = {path = "../../../RustPlayground/opus-rs"}
flutter_rust_bridge = "=2.1.0"
jni = "0.21.1"
log = "0.4.22"
ndk-context = "0.1.1"
rtcp = "0.11.0"
rtp-rs = "0.6.0"
rtrb = "0.3.1"
socket2 = "0.5.7"
[target.'cfg(any(target_os = "ios"))'.dependencies]
oslog = "0.2.0"
@dikatok I think it is possible!
I also tried manually configuring this following example 2 in the logging doc to no success either
Hmm, maybe try the underlying mechanism of that logging helper, i.e. call low-level things to directly log to system and see whether it works. Also maybe ask/discuss on the related crates (oslog for example), and/or rust forum, since it looks like a general Rust question "why logging does not work" and may not be related to frb core.
Approach 1: Use the default one
Setps:
adb logcat
[dependencies]
flutter_rust_bridge = { version = "=2.2.0", features = ["log"] }
log = "0.4.22"
use log::info;
#[flutter_rust_bridge::frb(sync)] // Synchronous mode for simplicity of the demo
pub fn greet(name: String) -> String {
println!("hello world");
info!("log:hello world");
format!("Hello, {name}!")
}
#[flutter_rust_bridge::frb(init)]
pub fn init_app() {
// Default utilities - feel free to customize
flutter_rust_bridge::setup_default_user_utils();
}
View all logs in one place. just try other Approach, such as Example 4: Send Rust logs to Dart Example 5: A step-by-step guide to send Rust logs to Dart
Approach 1: Use the default one
Setps:
- add log feature as below
- init log
- for ios (oslog), you can view the log with Instruments or Console App on macOS; for macos (oslog), same as ios. version 2.2.0 only for ios, so just wait for new version release.; for android (android_logger), you can view with
adb logcat
[dependencies] flutter_rust_bridge = { version = "=2.2.0", features = ["log"] } log = "0.4.22"
#[flutter_rust_bridge::frb(init)] pub fn init_app() { // Default utilities - feel free to customize flutter_rust_bridge::setup_default_user_utils(); }
View all logs in one place. just try other Approach, such as Example 4: Send Rust logs to Dart Example 5: A step-by-step guide to send Rust logs to Dart
Are the logs emitted by rust layer not exposed to flutter debug console by default?
Update Checked adb logcat and it yield no results as well. Will try using FRB as flutter app not as plugin later, and see if it works.
I created new app using flutter_rust_bridge_codegen create my_app
, added log macros warn
, info
, error
, none are emitted in either flutter debug console or adb logcat. 😢
I still guess it is probably an issue with the specific logging library, instead of a frb (core) issue. So asking/searching there may help, since the logging lib maintainers have more experience about what is going wrong than me about the logging library.
@dikatok
I created new app using flutter_rust_bridge_codegen create my_app, added log macros warn, info, error, none are emitted in either flutter debug console or adb logcat. 😢
Did you follow the steps above?
You should enable log feature flutter_rust_bridge = { version = "=2.2.0", features = ["log"] }
For Android
Note: adb logcat is just used for Android logs and even without use logcat you can see the log like this I/rust_lib_xxx::xx..(pid number): hello world
in the console, When you debug android.
Currently frb v2.2.0, the default utils only for Android and iOS, you can customize for support other platforms.
enabling the log
feature allows debug!
, info!
, and warn!
to show, but not println!
. also, a manual panic!
invocation isn't showing either. I'll look around on the platform specific logging crates to see if I can find anything that could help
edit: nevermind, panics are showing
println
will not show iirc because it is a builtin thing and cannot be very easily configured. happy to see it works!
so, shall we make the log
feature default enabled?
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.
Describe the bug
I'm trying to get some logs to show up in the console when I run my app. I have tried calling
println!
,debug!
,info!
andwarn!
, and no matter which I call, none of the messages I try to print show up.Steps to reproduce
Create a new project, and make a function called
test_logs()
and try this:run the generate command and call this function immediately, inside
initState()
, perhaps.and the output looks like this for me:
... nothing. I verified that the
flutter_rust_bridge::setup_default_user_utils()
was present. I also tried manually configuring this following example 2 in the logging doc to no success either, and made sure to add the correct bundle ID for ios as well.Where am I going wrong here?
Logs
Expected behavior
No response
Generated binding code
No response
OS
No response
Version of
flutter_rust_bridge_codegen
No response
Flutter info
No response
Version of
clang++
No response
Additional context
No response