Crates.io | flutter_logger |
lib.rs | flutter_logger |
version | 0.6.1 |
source | src |
created_at | 2023-07-12 10:17:28.105289 |
updated_at | 2024-03-10 13:05:05.432539 |
description | logging library for using rust together with flutter/dart and flutter_rust_bridge |
homepage | https://github.com/MnlPhlp/flutter_logger |
repository | https://github.com/MnlPhlp/flutter_logger |
max_upload_size | |
id | 914409 |
size | 56,636 |
implementation of the log
crate for using rust together with flutter/dart and flutter_rust_bridge to get logs from rust into your app.
panic
: print rust panics to the log stream.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
// 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}")
}
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.