Skip to content

Commit

Permalink
Merge pull request #1370 from not-holar/patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
fzyzcjy authored Sep 18, 2023
2 parents 6154e00 + a2d63a7 commit 2037e0a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions book/src/feature/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Since I have seen some questions asking how logging can be implemented with a Fl

## Logger in production

In my own app in production, I use the following strategy for Rust logging: Use normal Rust logging methods, such as `info!` and `debug!` macros. The logs are consumed in two places: They are printed via platform-specific methods (like android Logcat and iOS NSLog), and also use a Stream to send them to the Dart side such that my Dart code and further process it using the same pipeline as normal Dart logs (e.g. save to a file, send to server, etc).
In my own app in production, I use the following strategy for Rust logging: Use normal Rust logging methods, such as `info!` and `debug!` macros. The logs are consumed in two places: They are printed via platform-specific methods (like android Logcat and iOS NSLog), and also use a Stream to send them to the Dart side such that my Dart code and further process are using the same pipeline as normal Dart logs (e.g. save to a file, send to server, etc).

The *full* code related to logging in my app can be seen here: [#486](https://github.com/fzyzcjy/flutter_rust_bridge/issues/486).

Expand Down Expand Up @@ -58,7 +58,7 @@ And now we can happily log anything in Rust:
log_stream_sink.add(LogEntry { msg: "hello I am a log from Rust", ... })
```

Of course, you can implement a logger following the Rust's `log` crate wrapping this raw stream sink, then you can use standard Rust logging mechanisms like `info!`. I exactly did that in my project.
Of course, you can implement a logger following the Rust's `log` crate wrapping this raw stream sink, then you can use standard Rust logging mechanisms like `info!`. I did exactly that in my project.

### Example: Simple timer

Expand Down

0 comments on commit 2037e0a

Please sign in to comment.