Skip to content

Commit

Permalink
replace println with logs in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf committed Apr 20, 2021
1 parent 4a477e7 commit ecbb83b
Show file tree
Hide file tree
Showing 24 changed files with 56 additions and 56 deletions.
2 changes: 1 addition & 1 deletion examples/2d/many_sprites.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ fn tick(time: Res<Time>, sprites: Query<&Sprite>, mut query: Query<&mut PrintTim
timer.0.tick(time.delta());

if timer.0.just_finished() {
println!("Sprites: {}", sprites.iter().count(),);
warn!("Sprites: {}", sprites.iter().count(),);
}
}
}
2 changes: 1 addition & 1 deletion examples/app/drag_and_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ fn main() {

fn file_drag_and_drop_system(mut events: EventReader<FileDragAndDrop>) {
for event in events.iter() {
println!("{:?}", event);
info!("{:?}", event);
}
}
2 changes: 1 addition & 1 deletion examples/app/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ struct PrintMessageState {

fn print_message_system(mut state: ResMut<PrintMessageState>, time: Res<Time>) {
if state.timer.tick(time.delta()).finished() {
println!("{}", state.message);
info!("{}", state.message);
}
}
4 changes: 2 additions & 2 deletions examples/app/plugin_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl Plugin for PrintHelloPlugin {
}

fn print_hello_system() {
println!("hello");
info!("hello");
}

pub struct PrintWorldPlugin;
Expand All @@ -46,5 +46,5 @@ impl Plugin for PrintWorldPlugin {
}

fn print_world_system() {
println!("world");
info!("world");
}
4 changes: 2 additions & 2 deletions examples/asset/asset_loading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ fn setup(
// You might notice that this doesn't run! This is because assets load in parallel without
// blocking. When an asset has loaded, it will appear in relevant Assets<T>
// collection.
println!("{:?}", sphere.primitive_topology());
info!("{:?}", sphere.primitive_topology());
} else {
println!("sphere hasn't loaded yet");
info!("sphere hasn't loaded yet");
}

// You can load all assets in a folder like this. They will be loaded in parallel without
Expand Down
2 changes: 1 addition & 1 deletion examples/asset/custom_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ fn print_on_load(mut state: ResMut<State>, custom_assets: ResMut<Assets<CustomAs
return;
}

println!("Custom asset loaded: {:?}", custom_asset.unwrap());
info!("Custom asset loaded: {:?}", custom_asset.unwrap());
state.printed = true;
}
10 changes: 5 additions & 5 deletions examples/asset/custom_asset_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@ struct CustomAssetIo(Box<dyn AssetIo>);

impl AssetIo for CustomAssetIo {
fn load_path<'a>(&'a self, path: &'a Path) -> BoxedFuture<'a, Result<Vec<u8>, AssetIoError>> {
println!("load_path({:?})", path);
info!("load_path({:?})", path);
self.0.load_path(path)
}

fn read_directory(
&self,
path: &Path,
) -> Result<Box<dyn Iterator<Item = PathBuf>>, AssetIoError> {
println!("read_directory({:?})", path);
info!("read_directory({:?})", path);
self.0.read_directory(path)
}

fn is_directory(&self, path: &Path) -> bool {
println!("is_directory({:?})", path);
info!("is_directory({:?})", path);
self.0.is_directory(path)
}

fn watch_path_for_changes(&self, path: &Path) -> Result<(), AssetIoError> {
println!("watch_path_for_changes({:?})", path);
info!("watch_path_for_changes({:?})", path);
self.0.watch_path_for_changes(path)
}

fn watch_for_changes(&self) -> Result<(), AssetIoError> {
println!("watch_for_changes()");
info!("watch_for_changes()");
self.0.watch_for_changes()
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/ecs/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ fn event_trigger_system(
// prints events as they come in
fn event_listener_system(mut events: EventReader<MyEvent>) {
for my_event in events.iter() {
println!("{}", my_event.message);
info!("{}", my_event.message);
}
}
6 changes: 3 additions & 3 deletions examples/ecs/fixed_timestep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ fn main() {
}

fn frame_update(mut last_time: Local<f64>, time: Res<Time>) {
println!("update: {}", time.seconds_since_startup() - *last_time);
info!("update: {}", time.seconds_since_startup() - *last_time);
*last_time = time.seconds_since_startup();
}

fn fixed_update(mut last_time: Local<f64>, time: Res<Time>, fixed_timesteps: Res<FixedTimesteps>) {
println!(
warn!(
"fixed_update: {}",
time.seconds_since_startup() - *last_time,
);

let fixed_timestep = fixed_timesteps.get(LABEL).unwrap();
println!(
warn!(
" overstep_percentage: {}",
fixed_timestep.overstep_percentage()
);
Expand Down
2 changes: 1 addition & 1 deletion examples/input/char_input_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ fn main() {
/// This system prints out all char events as they come in
fn print_char_event_system(mut char_input_events: EventReader<ReceivedCharacter>) {
for event in char_input_events.iter() {
println!("{:?}: '{}'", event, event.char);
info!("{:?}: '{}'", event, event.char);
}
}
12 changes: 6 additions & 6 deletions examples/input/gamepad_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ fn connection_system(
match &event {
GamepadEvent(gamepad, GamepadEventType::Connected) => {
lobby.gamepads.insert(*gamepad);
println!("{:?} Connected", gamepad);
info!("{:?} Connected", gamepad);
}
GamepadEvent(gamepad, GamepadEventType::Disconnected) => {
lobby.gamepads.remove(gamepad);
println!("{:?} Disconnected", gamepad);
info!("{:?} Disconnected", gamepad);
}
_ => (),
}
Expand All @@ -45,23 +45,23 @@ fn gamepad_system(
) {
for gamepad in lobby.gamepads.iter().cloned() {
if button_inputs.just_pressed(GamepadButton(gamepad, GamepadButtonType::South)) {
println!("{:?} just pressed South", gamepad);
info!("{:?} just pressed South", gamepad);
} else if button_inputs.just_released(GamepadButton(gamepad, GamepadButtonType::South)) {
println!("{:?} just released South", gamepad);
info!("{:?} just released South", gamepad);
}

let right_trigger = button_axes
.get(GamepadButton(gamepad, GamepadButtonType::RightTrigger2))
.unwrap();
if right_trigger.abs() > 0.01 {
println!("{:?} RightTrigger2 value is {}", gamepad, right_trigger);
info!("{:?} RightTrigger2 value is {}", gamepad, right_trigger);
}

let left_stick_x = axes
.get(GamepadAxis(gamepad, GamepadAxisType::LeftStickX))
.unwrap();
if left_stick_x.abs() > 0.01 {
println!("{:?} LeftStickX value is {}", gamepad, left_stick_x);
info!("{:?} LeftStickX value is {}", gamepad, left_stick_x);
}
}
}
8 changes: 4 additions & 4 deletions examples/input/gamepad_input_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ fn gamepad_events(mut gamepad_event: EventReader<GamepadEvent>) {
for event in gamepad_event.iter() {
match &event {
GamepadEvent(gamepad, GamepadEventType::Connected) => {
println!("{:?} Connected", gamepad);
info!("{:?} Connected", gamepad);
}
GamepadEvent(gamepad, GamepadEventType::Disconnected) => {
println!("{:?} Disconnected", gamepad);
info!("{:?} Disconnected", gamepad);
}
GamepadEvent(gamepad, GamepadEventType::ButtonChanged(button_type, value)) => {
println!("{:?} of {:?} is changed to {}", button_type, gamepad, value);
info!("{:?} of {:?} is changed to {}", button_type, gamepad, value);
}
GamepadEvent(gamepad, GamepadEventType::AxisChanged(axis_type, value)) => {
println!("{:?} of {:?} is changed to {}", axis_type, gamepad, value);
info!("{:?} of {:?} is changed to {}", axis_type, gamepad, value);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions examples/input/keyboard_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ fn main() {
/// This system prints 'A' key state
fn keyboard_input_system(keyboard_input: Res<Input<KeyCode>>) {
if keyboard_input.pressed(KeyCode::A) {
println!("'A' currently pressed");
info!("'A' currently pressed");
}

if keyboard_input.just_pressed(KeyCode::A) {
println!("'A' just pressed");
info!("'A' just pressed");
}

if keyboard_input.just_released(KeyCode::A) {
println!("'A' just released");
info!("'A' just released");
}
}
2 changes: 1 addition & 1 deletion examples/input/keyboard_input_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ fn main() {
/// This system prints out all keyboard events as they come in
fn print_keyboard_event_system(mut keyboard_input_events: EventReader<KeyboardInput>) {
for event in keyboard_input_events.iter() {
println!("{:?}", event);
info!("{:?}", event);
}
}
2 changes: 1 addition & 1 deletion examples/input/keyboard_modifiers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ fn keyboard_input_system(input: Res<Input<KeyCode>>) {
let ctrl = input.pressed(KeyCode::LControl) || input.pressed(KeyCode::RControl);

if ctrl && shift && input.just_pressed(KeyCode::A) {
println!("Just pressed Ctrl + Shift + A!");
info!("Just pressed Ctrl + Shift + A!");
}
}
6 changes: 3 additions & 3 deletions examples/input/mouse_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ fn main() {
// This system prints messages when you press or release the left mouse button:
fn mouse_click_system(mouse_button_input: Res<Input<MouseButton>>) {
if mouse_button_input.pressed(MouseButton::Left) {
println!("left mouse currently pressed");
info!("left mouse currently pressed");
}

if mouse_button_input.just_pressed(MouseButton::Left) {
println!("left mouse just pressed");
info!("left mouse just pressed");
}

if mouse_button_input.just_released(MouseButton::Left) {
println!("left mouse just released");
info!("left mouse just released");
}
}
8 changes: 4 additions & 4 deletions examples/input/mouse_input_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ fn print_mouse_events_system(
mut mouse_wheel_events: EventReader<MouseWheel>,
) {
for event in mouse_button_input_events.iter() {
println!("{:?}", event);
info!("{:?}", event);
}

for event in mouse_motion_events.iter() {
println!("{:?}", event);
info!("{:?}", event);
}

for event in cursor_moved_events.iter() {
println!("{:?}", event);
info!("{:?}", event);
}

for event in mouse_wheel_events.iter() {
println!("{:?}", event);
info!("{:?}", event);
}
}
10 changes: 5 additions & 5 deletions examples/input/touch_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ fn main() {

fn touch_system(touches: Res<Touches>) {
for touch in touches.iter_just_pressed() {
println!(
info!(
"just pressed touch with id: {:?}, at: {:?}",
touch.id(),
touch.position()
);
}

for touch in touches.iter_just_released() {
println!(
info!(
"just released touch with id: {:?}, at: {:?}",
touch.id(),
touch.position()
);
}

for touch in touches.iter_just_cancelled() {
println!("cancelled touch with id: {:?}", touch.id());
info!("cancelled touch with id: {:?}", touch.id());
}

// you can also iterate all current touches and retrieve their state like this:
for touch in touches.iter() {
println!("active touch: {:?}", touch);
println!(" just_pressed: {}", touches.just_pressed(touch.id()));
info!("active touch: {:?}", touch);
info!(" just_pressed: {}", touches.just_pressed(touch.id()));
}
}
2 changes: 1 addition & 1 deletion examples/input/touch_input_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ fn main() {

fn touch_event_system(mut touch_events: EventReader<TouchInput>) {
for event in touch_events.iter() {
println!("{:?}", event);
info!("{:?}", event);
}
}
2 changes: 1 addition & 1 deletion examples/reflection/generic_reflection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn setup(type_registry: Res<TypeRegistry>) {
let type_registry = type_registry.read();

let registration = type_registry.get(TypeId::of::<MyType<u32>>()).unwrap();
println!("Registration for {} exists", registration.short_name());
info!("Registration for {} exists", registration.short_name());

// MyType<String> was not manually registered, so it does not exist
assert!(type_registry.get(TypeId::of::<MyType<String>>()).is_none());
Expand Down
2 changes: 1 addition & 1 deletion examples/reflection/reflection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fn setup(type_registry: Res<TypeRegistry>) {
let serializer = ReflectSerializer::new(&value, &type_registry);
let ron_string =
ron::ser::to_string_pretty(&serializer, ron::ser::PrettyConfig::default()).unwrap();
println!("{}\n", ron_string);
info!("{}\n", ron_string);

// Dynamic properties can be deserialized
let reflect_deserializer = ReflectDeserializer::new(&type_registry);
Expand Down
2 changes: 1 addition & 1 deletion examples/reflection/reflection_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn setup() {
// `Struct` is a trait automatically implemented for structs that derive Reflect. This trait
// allows you to interact with fields via their string names or indices
ReflectRef::Struct(value) => {
println!(
info!(
"This is a 'struct' type with an 'x' value of {}",
value.get_field::<usize>("x").unwrap()
)
Expand Down
2 changes: 1 addition & 1 deletion examples/reflection/trait_reflection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn setup(type_registry: Res<TypeRegistry>) {
let my_trait: &dyn DoThing = reflect_do_thing.get(&*reflect_value).unwrap();

// Which means we can now call do_thing(). Magic!
println!("{}", my_trait.do_thing());
info!("{}", my_trait.do_thing());

// This works because the #[reflect(MyTrait)] we put on MyType informed the Reflect derive to
// insert a new instance of ReflectDoThing into MyType's registration. The instance knows
Expand Down
12 changes: 6 additions & 6 deletions examples/scene/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn main() {
.add_startup_system(save_scene_system.exclusive_system())
.add_startup_system(load_scene_system.system())
.add_startup_system(infotext_system.system())
.add_system(print_system.system())
.add_system(log_system.system())
.run();
}

Expand Down Expand Up @@ -62,12 +62,12 @@ fn load_scene_system(asset_server: Res<AssetServer>, mut scene_spawner: ResMut<S
asset_server.watch_for_changes().unwrap();
}

// This system prints all ComponentA components in our world. Try making a change to a ComponentA in
// This system logs all ComponentA components in our world. Try making a change to a ComponentA in
// load_scene_example.scn. You should immediately see the changes appear in the console.
fn print_system(query: Query<(Entity, &ComponentA), Changed<ComponentA>>) {
fn log_system(query: Query<(Entity, &ComponentA), Changed<ComponentA>>) {
for (entity, component_a) in query.iter() {
println!(" Entity({})", entity.id());
println!(
info!(" Entity({})", entity.id());
info!(
" ComponentA: {{ x: {} y: {} }}\n",
component_a.x, component_a.y
);
Expand Down Expand Up @@ -95,7 +95,7 @@ fn save_scene_system(world: &mut World) {
let scene = DynamicScene::from_world(&scene_world, &type_registry);

// Scenes can be serialized like this:
println!("{}", scene.serialize_ron(&type_registry).unwrap());
info!("{}", scene.serialize_ron(&type_registry).unwrap());

// TODO: save scene
}
Expand Down

0 comments on commit ecbb83b

Please sign in to comment.