Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
MnlPhlp committed Jan 24, 2024
1 parent 69d3753 commit 63963f2
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,38 @@ implementation of the `log` crate for using rust together with flutter/dart and

## features

- `panic`: print rust panics to the log stream
- `panic`: print rust panics to the log stream.

## usage

This code is not complete. Look into the example folder for a full working example.
The library contains a macro for all the code you have to include in your flutter_rust_bridge api definition.

### rust

```rs
flutter_logger::flutter_logger_init!(LevelFilter::Info);

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

pub fn init(sink: StreamSink<LogEntry>) {
flutter_logger::init(sink).unwrap();
}
```

### dart/flutter

```dart
final rust_lib =
void setupLogger(){
rustLib.init().listen((msg){
setupLogStream().listen((msg){
// This should use a logging framework in real applications
print("${msg.logLevel} ${msg.lbl.padRight(8)}: ${msg.msg}");
});
}
void main(){
setupLogger();
rustLib.test(i: 5);
await RustLib.init();
await setupLogger();
await test(i: 5);
}
```
Expand Down

0 comments on commit 63963f2

Please sign in to comment.