-
Notifications
You must be signed in to change notification settings - Fork 45
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
Apply env_logger
module filters on Dart & UniFFI binding loggers
#874
base: main
Are you sure you want to change the base?
Conversation
b544d81
to
265f0d6
Compare
logger.rs
env_logger
module filters on Dart & UniFFI binding loggers
18a4b02
to
39d9220
Compare
086d763
to
2bbebbb
Compare
Depends on:
|
libs/sdk-core/src/logger.rs
Outdated
}); | ||
} | ||
|
||
pub struct UniFFILogger { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why taking the specific loggers out of their specific crates?
Doesn't UniFFILogger belong to the sdk-bindings crate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessarily, the loggers are not exposed through bindings.
I had brought them together to see the differences to find the root cause of the issue, and I prefer having them together, but we can bring them back to uniffi_bindings.rs
& bindings.rs
with little to no change.
If we expand upon logger settings as mentioned on #892, it would be hard to miss applying new changes on bindings when they are grouped together like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree putting these in the bindings crate seems logical
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
94788be
to
66df72b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK! A few nits. (And ofcourse this needs a rebase, which will be painful)
libs/sdk-core/src/logger.rs
Outdated
debug, | ||
breez_sdk_core::backup=info, | ||
breez_sdk_core::breez_services=info, | ||
breez_sdk_core::input_parser=warn, | ||
breez_sdk_core::persist::reverseswap=info, | ||
breez_sdk_core::reverseswap=info, | ||
gl_client::node=info, | ||
gl_client::node::service=info, | ||
gl_client::tls=info, | ||
gl_client::scheduler=info, | ||
gl_client::signer=info, | ||
gl_client=debug, | ||
h2=warn, | ||
h2::client=info, | ||
h2::codec::framed_read=warn, | ||
h2::codec::framed_write=warn, | ||
h2::proto::connection=info, | ||
h2::proto::settings=info, | ||
hyper=warn, | ||
hyper::client::connect::dns=info, | ||
hyper::client::connect::https=info, | ||
lightning_signer=warn, | ||
lightning_signer::node=warn, | ||
reqwest=warn, | ||
reqwest::connect=warn, | ||
rustls=warn, | ||
rustls::anchors=warn, | ||
rustls::conn=warn, | ||
rustls::client::common=warn, | ||
rustls::client::hs=warn, | ||
rustls::client::tls13=warn, | ||
rustyline=warn, | ||
rusqlite_migration=warn, | ||
tower::buffer::worker=warn, | ||
vls_protocol_signer=warn, | ||
vls_protocol_signer::handler::HandlerBuilder::do_build=warn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: I've changed the log filters in #1098
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the missing sdk_common=debug,
should be enough imo.
We can make the necessary individual changes after making comparisons if there are any.
libs/sdk-core/src/logger.rs
Outdated
writeln!( | ||
buf, | ||
"[{} {} {}:{}] {}", | ||
Local::now().format("%Y-%m-%d %H:%M:%S%.3f"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use UTC if possible with ISO8601 format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Done.
Switch timestamp format from local to UTC in ISO 8601 format
libs/sdk-core/src/logger.rs
Outdated
}); | ||
} | ||
|
||
pub struct UniFFILogger { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree putting these in the bindings crate seems logical
Dart, UniFFI & GlobalSDK logger's are moved under logger.rs .
- Create LevelFilter struct that's usable from bindings. - Add optional filter_level param to binding logger init & setters - Map models:LevelFilter to log::LevelFilter. - Set LevelFilter::TRACE as default filter level
Log `UNUSUAL` level node logs at `Error` level
66df72b
to
7c23fbf
Compare
Errors made around import resolution(sdk-common changes etc.) & removal of a crate introduced on this PR
8f661bb
to
ef70a96
Compare
8842abf
to
32aef81
Compare
32aef81
to
7d3a462
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a few comments
); | ||
} | ||
*guard = Some(stream_sink); | ||
drop(guard) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done automatically when the guard goes out of scope.
use log::{ | ||
max_level, set_boxed_logger, set_max_level, warn, Log, Metadata, Record, STATIC_MAX_LEVEL, | ||
}; | ||
use parking_lot::RwLock; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason to use parking_lot
here? Can we use std::sync::RwLock
or tokio::sync::RwLock
?
let prefix_len = l.line.find(':').map_or(0, |len| len + 2); | ||
let log_message = l.line.split_at(prefix_len).1.trim_start(); | ||
match l.line.to_ascii_lowercase().as_str() { | ||
s if s.starts_with("unusual") => error!("node-logs: {}", log_message), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think unusual
can be warn
And broken
needs to be added as error
breez_sdk_core::backup=info, | ||
breez_sdk_core::breez_services=info, | ||
breez_sdk_core::input_parser=warn, | ||
breez_sdk_core::persist::reverseswap=info, | ||
breez_sdk_core::reverseswap=info, | ||
sdk_common=debug, | ||
gl_client::node=info, | ||
gl_client::node::service=info, | ||
gl_client::tls=info, | ||
gl_client::scheduler=info, | ||
gl_client::signer=info, | ||
gl_client=debug, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, debug
level logs would be filtered out regardless of the client's loglevel. I would put all these at debug, or even trace, because they would eventually be filtered out by the client log level.
/* env_logger */ | ||
|
||
const ENV_LOGGER_FILTER: &str = r#" | ||
debug, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should either depend on client log level or be info
in my opinion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should create one of these filter statements per log level
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These RN codegen changes in breez/breez-sdk-rn-generator#23 should be applied in libs/sdk-bindings/bindings-react-native
This PR addresses the issue where env_logger's module filters were not applying to logs listened through Dart & UniFFI binding loggers.
Changelist:
env_logger
module filterslogger.rs
LevelFilter
struct that's usable from bindings.filter_level
param to binding logger init & settersmodels:LevelFilter
tolog::LevelFilter
.LevelFilter::TRACE
as default filter levelTODO: