-
Notifications
You must be signed in to change notification settings - Fork 284
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 "Log messages to the console" recipe #69
Conversation
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.
- Textual description needs to be added
- Table entries in intro.md should be updated as well
- as mentioned in https://github.com/brson/rust-cookbook/issues/61#issuecomment-300764482 i would suggest making it a more advanced separate example. Something along the lines of "Creating a custom logger". As the trivial consol logging would be implemented in 5 line
env_logger
snippet
src/app.md
Outdated
@@ -3,8 +3,7 @@ | |||
| Recipe | Crates | Categories | | |||
|--------|--------|------------| | |||
| [Parse command line arguments][ex-clap-basic] | [![clap-badge]][clap] | [![cat-command-line-badge]][cat-command-line] | | |||
| [Log a debug message to the console][ex-log-debug] | [![log-badge]][log] [![env_logger-badge]][env_logger] | [![cat-command-line-badge]][cat-command-line] | | |||
| [Log an error message to the console][ex-log-error] | [![log-badge]][log] [![env_logger-badge]][env_logger] | [![cat-command-line-badge]][cat-command-line] | | |||
| [Log messages to the console][ex-log-messages] | [![log-badge]][log] [![env_logger-badge]][env_logger] | [![cat-command-line-badge]][cat-command-line] | |
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.
badges do not reflect the used crates please see the env_logger-badge
also [![cat-command-line-badge]][cat-command-line] should be changed to [![cat-debugging-badge]][cat-debugging]
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.
Thanks again for your help. So you mean replacing:
| [Log messages to the console][ex-log-messages] | [![log-badge]][log] [![env_logger-badge]][env_logger] | [![cat-command-line-badge]][cat-command-line] |
By
| [Log messages to the console][ex-log-messages] | [![log-badge]][log] | [![cat-debugging-badge]][cat-debugging] |
Ok I could do that!
src/app.md
Outdated
## Log a debug message to the console | ||
[ex-log-messages]: #ex-log-messages | ||
<a name="ex-log-messages"></a> | ||
## Log messages to the console | ||
|
||
[![log-badge]][log] [![env_logger-badge]][env_logger] [![cat-command-line-badge]][cat-command-line] |
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.
spurious env_logger-badge
Then in #61:
I think I totally misunderstood what you wrote in https://github.com/brson/rust-cookbook/issues/61 AND I think I still don't understand! I thought you said "Your example is OK because it has some details". But now, I'm lost. Thinking about it, I'm not sure anymore I have a sufficient level to do such a PR (english level+rust level+brain level). Honestly, what do you think? Can I give up? (cause maybe it's a waste of time, somebody else would have done better work) If not, will you have the patience to continue to help me? Thanks again for your help! |
@rap2hpoutre You should definitely not give up 🥇 as you PR is almost perfect, and please note that this repository is an outreach program for people to learn and be a first step in contribution. Honestly my english not top notch, so we might have misunderstood, so let me rephrase:
|
(edited) @budziq OK so I could:
Right? |
I agree with @budziq, this example is really valuable but not as the very first @rap2hpoutre please rename this example to something like "Log messages in a custom format" and tweak something trivial about it to make it custom, like: println!("Rust says: {} - {}", record.level(), record.args()); Then please add an example above this one showing a minimal very basic use of |
@dtolnay Ok thanks. I updated my todo-list above your comment. Ok with this? |
Yes that covers everything. Thank you! |
Ok I will try to do it tomorrow! |
I close this PR because:
New clean (I hope) PR here: #74 (with the right title, description, no conflict, no random commit messages, etc.) Thanks to @budziq & @dtolnay for their help!! |
See https://github.com/brson/rust-cookbook/issues/61
I choose to replace "Log a debug message to the console" and "Log an error message to the console" by just "Log messages to the console" (which covers info, warn and error), because recipe is (imo) almost the same for the various message levels. Maybe I'm wrong.
I'm still learning and need mentoring, maybe the quality of my PR is a bit poor. Anyway, thanks to @budziq for his precious help.
I could add a text description around this example later, but today I'm not really inspired (and to be fair I'm not fluent at all in english, so I'm a bit scared).