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

Add logs using logs #223

Merged
merged 3 commits into from
Oct 15, 2024
Merged

Add logs using logs #223

merged 3 commits into from
Oct 15, 2024

Conversation

soywod
Copy link
Contributor

@soywod soywod commented Oct 11, 2024

Closes #221.

This PR adds basic log support using the tracing crate. It gives more context to users about what is going on inside keyring-rs.

@soywod
Copy link
Contributor Author

soywod commented Oct 11, 2024

More logs can be added if #222 is accepted and merged, so I leave this PR in draft for now.

Copy link
Collaborator

@brotskydotcom brotskydotcom left a comment

Choose a reason for hiding this comment

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

  1. If you change the dependency to be on the logs crate, then you won't have to conditionalize the logging code at all, which will provide an enormous simplification. (See my comments on Add logs support #221 for other reasons I prefer logs to tracing.)
  2. When creating an entry, please be sure to log the credential-store-specific attributes being used as well as the credential store. (Since all of the stores derive Debug, you can just debug print the credential into the log.)
  3. When operating on an entry, be sure to debug log the entry. That way it can be correlated to where the entry was created.
  4. I suggest you move logging of the target, service, and user into the platform-independent code, which saves you adding it to the credential-store code. Then the credential-store code can just debug log the credential being operated on.

@soywod soywod mentioned this pull request Oct 13, 2024
@soywod soywod force-pushed the tracing branch 2 times, most recently from 303424b to 6dd0633 Compare October 14, 2024 07:48
Also used env_logger for tests.
@soywod soywod marked this pull request as ready for review October 14, 2024 07:52
@soywod
Copy link
Contributor Author

soywod commented Oct 14, 2024

The PR is ready for review. In fact it can be mergde before or after #222, it does not matter.

I try to apply what you asked for, let me know if it's what you have in mind. I added env_logger for integration tests, so you can easily get logs with RUST_LOG=debug. I enabled it for the CI so we have logs always available, in case of. Just a proposition.

@soywod soywod requested a review from brotskydotcom October 14, 2024 07:55
@brotskydotcom brotskydotcom changed the title Add logs using tracing Add logs using logs Oct 14, 2024
Copy link
Collaborator

@brotskydotcom brotskydotcom left a comment

Choose a reason for hiding this comment

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

This looks very good, thank you! Minor language cleanups and format cleanups and a question for you to consider.

@soywod soywod requested a review from brotskydotcom October 15, 2024 19:13
Copy link
Collaborator

@brotskydotcom brotskydotcom left a comment

Choose a reason for hiding this comment

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

Perfect! Thanks so much for this! I will merge it right away, so you can rebase #222 on it.

@brotskydotcom brotskydotcom merged commit cad3c7b into hwchen:master Oct 15, 2024
13 checks passed
@soywod soywod deleted the tracing branch October 15, 2024 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add logs support
2 participants