-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: use Rust standard logging. #16
feat: use Rust standard logging. #16
Conversation
This commit removes all the "println" that were in the repository to use Rust's standard "log" crate instead (which is maitained by the Rust core team). All the library / infrastructure parts of the keybroker-demo repository only use the "log::error", "log::warn", "log::info", "log::debug" functions from the logging facade. The actual executables (keybroker-server, keybroker-app) instantiate and configure an implementation of a logger. The stderrlog is used here as it is simple minimal logger, but https://docs.rs/log/latest/log/ lists many more available logging implementations. The keybroker-server and keyborker-app do use the same command line options with respect to logging control (verbose / quiet). The verbose switch can be specified multiple times to increase verbosity. Signed-off-by: Arnaud de Grandmaison <[email protected]>
Looks good. Just a question. Being a (relative) neophyte in the Rust world, I am ignorant of how the verbosity number maps to the log level. Is this a straight:
so that to get the If the latter, could you please explain the expectations for the CLI caller? |
The logging is done thru one of the five macros:
If you experiment with it, you'll notice that some of our dependencies are using the
The one point that may be debatable is that I've enabled the warnings by default. I believe it is a sound default given the purpose of keybroker-demo code base (education). For production code, warnings would probably have to be filtered, but for education and people experimenting, I feel more at ease with providing them with details when something is not quite right (a warning). |
Thanks for the detailed description. Much appreciated!
Cool - this is a consequence of the first piece of your explanation IIUC.
👍 |
Could you add this table to a |
Not sure we need a whole separate markdown file for that? It might be better to move towards enhancing the README, which is currently a bit threadbare. Perhaps we need a follow-up PR to add building/running guides to the README, and then we can include the verbosity table as a sub-heading of that? |
Aggreed, I was not thrilled by a separate logging.md file. I propose to add sketch sections (building, running and logging) with lightweight content as part of this patch, and some subsequent PR / patch can fill them with more details. |
I am ok with all proposals as long as the information captured in #16 (comment) is made permanently visible in the codebase :-) |
This adds 2 sections on building and running the keybroker-demo executables. It also adds a section about logging and how the verbosity is controlled from the commadn line. Signed-off-by: Arnaud de Grandmaison <[email protected]>
0cb2cb6
to
4cf1675
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.
LGTM, thanks!
Use a more transparent way of passing the reference value to the keybroker-server in the example in the documentation. Signed-off-by: Arnaud de Grandmaison <[email protected]>
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.
Looks great, thank you.
This commit removes all the "println" that were in the repository to use Rust's standard "log" crate instead (which is maitained by the Rust core team).
All the library / infrastructure parts of the keybroker-demo repository only use the "log::error", "log::warn", "log::info", "log::debug" functions from the logging facade.
The actual executables (keybroker-server, keybroker-app) instantiate and configure an implementation of a logger. The stderrlog implementation is used here as it is simple minimal logger, but https://docs.rs/log/latest/log/ lists many more available logging implementations.
The keybroker-server and keyborker-app do use the same command line options with respect to logging control (verbose / quiet). The verbose switch can be specified multiple times to increase verbosity.