fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.

Home Page:https://fzyzcjy.github.io/flutter_rust_bridge/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mention flutter_logger in "send logs to dart" section

MnlPhlp opened this issue · comments

Is your feature request related to a problem? Please describe.
The documentation mentions how you could implement a logging logic to pass rust log messages to dart in Example 3: Send Rust logs to Dart.
It's tedious to do this for single projects so i created the crate flutter_logger that set's up everything with one macro call.

Describe the solution you'd like
If it is ok with you i would like to mention this in the doc section about logging.
Especially for new users of the library this might make stuff easier.
I can do a pull request with a short description/mention of the crate if it is something of interest.

Also feel free to just close this issue if you don't want this mentioned somewhere.

Describe alternatives you've considered
Alternative is implementing the logging for each app yourself.

Additional context
Example:

rust

flutter_logger::flutter_logger_init!();

pub fn test(i: i32) {
    // using the 'log' crate macros
    info!("test called with: {i}")
}

dart/flutter

void setupLogger(){
    setupLogStream().listen((msg){
    // This should use a logging framework in real applications
        print("${msg.logLevel} ${msg.lbl.padRight(8)}: ${msg.msg}");
    });
}

void main(){
    await RustLib.init();
    await setupLogger();
    await test(i: 5);
}

Looks great and thanks for pointing out :) I will add that to doc.

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.