-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
Add logs support #221
Comments
Hi @soywod, I'm afraid I'm not convinced of the utility of this, and the samples in your PR are not convincing me otherwise. It's not like the internals of keyring are interesting from a client point of view, except maybe from performance perspective, and no one's been complaining. Is there a use case you have in mind? |
IMHO, adding logs to a lib is really a must. It gives lib consumers more context about what is happening internally, and at a bigger scale (let's say at app level), it also helps to debug. Adding few logs here and there in My main motivation comes from an issue one of my user opened: passwords were not persisting. I could not reproduce the issue. App logs showed that everything was fine, but he just could not get his freshly-defined password. After a long research I assumed that it was internally using the mock keystore (potentially due to a missing cargo feature). Having just a simple log Other arguments are:
Side note: it could be great that other tools made by you guys support logs as well: |
Another argument for #222: logs let us know if a secret/password has been found in the keyutils cache or not, with the underlaying error. if let Some(keyutils) = &self.keyutils {
if let Ok(password) = keyutils.get_password() {
return Ok(password);
}
} becomes: if let Some(keyutils) = &self.keyutils {
let _res = keyutils.get_password();
#[cfg(feature = "tracing")]
match _res {
Ok(password) => {
tracing::debug!("password found from keyutils");
return Ok(password)
}
Err(err) => {
tracing::debug!(?err, "cannot find password from keyutils");
}
}
} |
OK, I see where we are talking past each other here. :) If you are suggesting that keyutils should do debug logging, for example of the default keystore choice, and what the computed target and other attributes are for each entry, then yes, by all means, I've been meaning to do that for a long time but have just not gotten around to it. I would love to see a PR that introduces logging (using the logs crate), and I would be very grateful for it! IMHO, the beauty of adding logging in this way is that it leaves it up to the application client to decide how they want to be handling logs, including whether they want to be doing tracing and set up spans for each call into keyring. The examples you gave above are all, in the language of the tracing crate, events not spans, so can be output via logging. Would you be willing to contribute logging rather than tracing? |
I'm not sure to understand the reason you propose
The I would really advise to go with |
I just read your comment in the PR #223 (review), I just want to precise that in my example, Also, I apologize in advance if I misunderstand your arguments for |
Hi Clément, I know a lot about tracing, and I use it in several apps. I do feel strongly that we use logs instead. Here's why:
Hope this helps clarify. |
With the actual code,
Which is not the case of
That said, by activating the
Do you have documentation about this statement? AFAIK
Isn't it the same for Sorry to insist, but it is not part of my principles to apply rules without fully understanding them. I do not try to agree at all cost, I would switch to blessed.rs states the following (which I agree):
|
Happy to have you insist - isn't that the point of open source? To discuss until we find a position we can agree on? So to your points:
To your postscript about blessed.rs: I would argue that the entries there actually point in the direction of Let me know if you find this convincing. |
Sure, you're right!
By using Also, since I'm convinced enough, I will refactor the PR as soon as we merge #222. I will take care of that tomorrow. Thank you for you patience. |
Thank YOU for being such a thoughtful and persistent contributor!! |
It could be a great and useful addition to add the
tracing
crate behind a feature gate and to emit logs. I can propose a PR if you are interested in seach feature.The text was updated successfully, but these errors were encountered: