#flutter #logging #dart #debugging-logging #mobile

flutter_logger

logging library for using rust together with flutter/dart and flutter_rust_bridge

7 releases (breaking)

0.6.1 Mar 10, 2024
0.6.0 Feb 7, 2024
0.5.0 Jan 24, 2024
0.4.0 Aug 16, 2023
0.1.0 Jul 12, 2023

#343 in FFI

Download history 101/week @ 2024-10-12 173/week @ 2024-10-19 129/week @ 2024-10-26 251/week @ 2024-11-02 203/week @ 2024-11-09 168/week @ 2024-11-16 28/week @ 2024-11-23 87/week @ 2024-11-30 109/week @ 2024-12-07 105/week @ 2024-12-14 10/week @ 2024-12-21 11/week @ 2024-12-28 30/week @ 2025-01-04 41/week @ 2025-01-11 35/week @ 2025-01-18 40/week @ 2025-01-25

146 downloads per month

MIT/Apache

28KB
626 lines

flutter_logger

implementation of the log crate for using rust together with flutter/dart and flutter_rust_bridge to get logs from rust into your app.

features

  • panic: print rust panics to the log stream.

usage

The library contains a macro for all the code you have to include in your flutter_rust_bridge api definition. Calling the macro without args creates the init function "setup_log_stream" with LeveFilter::Debug. You can also specify function name and LevelFilter (or only one). The macro can only be called once because of conflicting implementations

rust


// only one of these calls can be active
flutter_logger::flutter_logger_init!(); // default
// flutter_logger::flutter_logger_init!(LeveFilter::Trace); // sepcify level
// flutter_logger::flutter_logger_init!(logger_init); // sepcify name
// flutter_logger::flutter_logger_init!(info_logger, LevelFilter::Info); // sepcify both

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

dart/flutter

Future setupLogger() async {
    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);
}

This works also on mobile apps like Android where println() in rust isn't shown in the console.

Dependencies

~135KB

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy