Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging Overhaul #2308

Draft
wants to merge 73 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
add0e0e
implements rust side logging
patmuk Sep 13, 2024
279fd76
wip, prepares Rust to log receiving a Closure
patmuk Sep 13, 2024
bb84765
using stream instead of function, compiles but doesn't log from rust
patmuk Sep 14, 2024
f203965
makes log crate work
patmuk Sep 14, 2024
b9ec1b5
removes all debug loggs
patmuk Sep 14, 2024
c8175e9
cleans up test logs
patmuk Sep 15, 2024
70ba4c0
simplifies by removing statics
patmuk Sep 15, 2024
6fee2fa
enables changing the log level on the rust side
patmuk Sep 15, 2024
9dc1827
wip: enables setting the level from Dart
patmuk Sep 15, 2024
a3577fa
implements setting the log level from dart and propergate it to rust
patmuk Sep 16, 2024
c6cf9c3
uses converted Log Records instread of Strings
patmuk Sep 16, 2024
2d07ad0
takes the log level as an optional parameter, defaulting to INFO
patmuk Sep 16, 2024
831f924
takes a log function as an optional parameter
patmuk Sep 16, 2024
143f91b
custom log function can be changed
patmuk Sep 16, 2024
e783a2c
documents logging
patmuk Sep 16, 2024
4e7e084
renames dart_minimal to dart_logging and implements examples in main.…
patmuk Sep 17, 2024
28dbcc7
reverts dart_minimal back to the original form
patmuk Sep 17, 2024
762ebc3
improves the examples and sets the log level so we actually see the r…
patmuk Sep 17, 2024
46debda
implements loggign test
patmuk Sep 18, 2024
c6a1fba
moves the dart logging dependency to the runtime
patmuk Sep 18, 2024
2ed86e2
removes the native mobile logger crates
patmuk Sep 18, 2024
72986f7
removes the native mobile logger crates
patmuk Sep 18, 2024
d8f98e3
removes the native mobile logger crates
patmuk Sep 18, 2024
6a8c74e
moves logging code (generated and hand written) to the runtimes frb_r…
patmuk Sep 19, 2024
3b6791d
compiles by initializing the thread handler
patmuk Sep 19, 2024
63cfd1a
compiles, but error at dart run
patmuk Sep 20, 2024
4328556
working logging code inside the project (dart_minimal)
patmuk Sep 23, 2024
2107c9f
Merge branch 'fzyzcjy:master' into logging_overhaul
patmuk Sep 23, 2024
d1ca127
working (all code in project)
patmuk Sep 23, 2024
2a1fa71
inlines the rust code into minimal.rs
patmuk Sep 23, 2024
1ed8a4a
removes the logging code from `frb_rust`
patmuk Sep 23, 2024
a592be8
fixes rust lint
patmuk Sep 23, 2024
a350c1a
removes the non-macro code integration
patmuk Sep 23, 2024
04d248c
removes `dart_logging`
patmuk Sep 23, 2024
69ba52d
moves dart code to dart_code attribute and adapts usage
patmuk Sep 23, 2024
88611cf
dart_code minimized
patmuk Sep 24, 2024
e85d08b
implements loggign of panics
patmuk Sep 24, 2024
d21a220
implements taking log level from env
patmuk Sep 24, 2024
bcd6c16
updates the documentation describing env LOG_LEVEL
patmuk Sep 24, 2024
37ee1f3
simplifies and implements from trait
patmuk Sep 25, 2024
d834ae1
removes DartLog enum
patmuk Sep 25, 2024
372c77a
removes the need to import the dart logging package and adds a method…
patmuk Sep 25, 2024
50509b4
accepts the log level as a String
patmuk Sep 25, 2024
470b7f0
code moved to a macro
patmuk Sep 25, 2024
9bf6548
removes unneeded code
patmuk Sep 25, 2024
fb3e040
removes oppinionated logging
patmuk Sep 25, 2024
e749e10
removes import 'package:logging/logging.dart'; from frb.yaml
patmuk Sep 25, 2024
535a1b8
documents the need for log = "0.4.20" in the cargo.toml
patmuk Sep 25, 2024
977c164
adds log to the cargo.lock template
patmuk Sep 26, 2024
2cd4efd
finishes the documentation
patmuk Sep 26, 2024
ccedb6c
code cleanup
patmuk Sep 26, 2024
3967aef
removes extra lines
patmuk Sep 26, 2024
d05b9d7
revertes changes on boilerplate.rs
patmuk Sep 26, 2024
15ca6ae
surpress a wrong clippy
patmuk Sep 26, 2024
6e2f0b5
Merge branch 'master' into logging_overhaul
patmuk Sep 26, 2024
554077e
Revert "removes oppinionated logging"
patmuk Sep 26, 2024
b164cf8
changes the default log output to look closer to log crate's output
patmuk Sep 26, 2024
d143bff
changes the default logger name to "FRBLogger"
patmuk Sep 28, 2024
f677e05
improves ergonomics
patmuk Sep 29, 2024
afa24e8
removes the #[cfg(wasm)] lint as this will be fixed by PR #2329
patmuk Sep 29, 2024
1bf560f
implements doc improvement suggestion
patmuk Sep 29, 2024
6c29c6f
marks dependencies as optional
patmuk Sep 29, 2024
f45a11d
removes all `use` statements to not confuse the user
patmuk Sep 29, 2024
cf46343
removes an overlooked clippy attribute
patmuk Sep 29, 2024
5af549f
sets logging dependency to 1.2.0
patmuk Sep 29, 2024
3d66d87
removes overlooked commented line
patmuk Sep 29, 2024
fcc6051
Merge branch 'master' into logging_overhaul
patmuk Sep 30, 2024
8a000eb
removes duplicated dependency
patmuk Sep 30, 2024
4591de7
addds clippy surpression
patmuk Sep 30, 2024
3705b93
changes a dart function name into camel case
patmuk Sep 30, 2024
b561524
changes a rust function name into proper snake case
patmuk Sep 30, 2024
009e2a1
adds chrono as default and removes it from the user project
patmuk Oct 1, 2024
290c100
Merge branch 'master' into logging_overhaul
patmuk Oct 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 3 additions & 54 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, maybe we can add a few lines in codegen to sanity check, if we find the string setup_default_user_utils, maybe we just log::warn!("Please migrate to new default user utils, see some_url_link_here for details") in codegen.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would be great!

Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ crate-type = ["cdylib", "staticlib"]

[dependencies]
flutter_rust_bridge = REPLACE_ME_RUST_FRB_DEPENDENCY
log = "0.4.20" # Optional - can be removed if you do not want logging
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ macro_rules! codegen_generator_structs {
}

$(
#[allow(dead_code)]
#[derive(Debug, Clone)]
pub(crate) struct [<$name $generator_name>]<'a> {
pub(crate) mir: [<MirType $name>],
Expand Down
2 changes: 2 additions & 0 deletions frb_codegen/src/library/utils/logs.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Utilities related to logging

// TODO remove when logging is implemented

use crate::utils::console::MULTI_PROGRESS;
use fern::colors::{Color, ColoredLevelConfig};
use log::LevelFilter;
Expand Down
53 changes: 1 addition & 52 deletions frb_example/dart_build_rs/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frb_example/dart_minimal/flutter_rust_bridge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ local: true
# TODO temp
#full_dep: true
#enable_lifetime: true
#stop_on_error: true
#stop_on_error: true
5 changes: 4 additions & 1 deletion frb_example/dart_minimal/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import 'package:frb_example_dart_minimal/src/rust/api/minimal.dart';
import 'package:frb_example_dart_minimal/src/rust/frb_generated.dart';

final LOGGER = FRBLogger.getLogger();

// If you are developing a binary program, you may want to put it in `bin/something.dart`
Future<void> main() async {
await RustLib.init();
print('Call Rust and get: 100+200 = ${await minimalAdder(a: 100, b: 200)}');
LOGGER.info(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can make the LOGGER only used from Rust. If some Dart users want to do logging, just follow the https://pub.dev/packages/logging doc and create another new logger.

Copy link
Contributor Author

@patmuk patmuk Sep 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored it now so that a user can just do that.
Though instead of final LOGGER = Logger('my logger'); he would call final LOGGER = FRBLogger.getLogger('my logger'); at least once.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I will check this in the next round review)

'Call Rust and get: 100+200 = ${await minimalAdder(a: 100, b: 200)}');
}
Loading
Loading