-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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 print_stdout
and print_stderr
lints (#17446)
#18233
Add print_stdout
and print_stderr
lints (#17446)
#18233
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
@@ -12,6 +12,7 @@ | |||
)] | |||
|
|||
use bevy_ecs::prelude::*; | |||
use log::info; |
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.
In examples we should be using bevy's re-exports of this, but since this is in bevy_ecs
's dedicated examples this is fine.
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.
Really thorough work. Thank you!
a5138bc
to
c87d1d8
Compare
I've missed some things. I'll change this back to 'ready for review' when all the automated checks pass. |
1d428ee
to
8c32b8a
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.
Nice! Standardising the code-base (and explicitly annotating exceptions with expect
) is always worth it, even ignoring the no_std
benefits.
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.
you changed a few tests where they should continue to use println
. loggers are often not set for tests
@@ -37,7 +38,7 @@ fn main() { | |||
|
|||
// Simulate 10 frames in our world | |||
for iteration in 1..=10 { | |||
println!("Simulating frame {iteration}/10"); | |||
info!("Simulating frame {iteration}/10"); |
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.
logger is also not set in this file so it should still use println
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.
should this have a #[cfg(feature="std)]
then?
crates/bevy_ecs/examples/events.rs
Outdated
@@ -2,6 +2,7 @@ | |||
//! If an event was send, it will be printed by the console in a receiving system. | |||
|
|||
use bevy_ecs::{event::EventRegistry, prelude::*}; | |||
use log::info; |
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.
same here, this should keep using println
@@ -7,6 +7,7 @@ | |||
)] | |||
|
|||
use bevy_ecs::prelude::*; | |||
use log::info; |
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.
same here, this should keep using println
@@ -283,7 +281,7 @@ impl<'scope, 'env: 'scope, 'sys> Context<'scope, 'env, 'sys> { | |||
.push(SystemResult { system_index }) | |||
.unwrap_or_else(|error| unreachable!("{}", error)); | |||
if let Err(payload) = res { | |||
eprintln!("Encountered a panic in system `{}`!", &*system.name()); | |||
log::error!("Encountered a panic in system `{}`!", &*system.name()); |
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.
there's no guarantee a logger is set here and this error is too important to risk to hide, it should keep using eprintln
very few of the existing |
9dc3900
to
82fa507
Compare
this is still changing too many println to logs. those changes should be reverted |
82fa507
to
3fbd313
Compare
3fbd313
to
e5b15f2
Compare
I reverted the changes from prints to logs and used |
All changes to log have been removed.
Objective
println!
,eprintln!
and the like because they requirestd
eprintln
andprintln
and preferlog
and/ortracing
#17446Solution
print_stdout
andprint_stderr
clippy lintsprintln!
andeprintln!
occurrences withlog::*
where applicable or alternatively ignore the warningsTesting
cargo clippy --workspace
to ensure that there are no warnings relating to printing tostdout
orstderr