From 7b67583cf673818fd7822aff654590dbe8947cd1 Mon Sep 17 00:00:00 2001 From: Carter Anderson Date: Tue, 10 Nov 2020 20:35:20 -0800 Subject: [PATCH] add bevy_log crate --- Cargo.toml | 14 +--- crates/bevy_app/Cargo.toml | 4 +- crates/bevy_app/src/app.rs | 2 +- crates/bevy_app/src/app_builder.rs | 3 +- crates/bevy_app/src/plugin_group.rs | 4 +- crates/bevy_asset/Cargo.toml | 1 - crates/bevy_core/Cargo.toml | 2 - crates/bevy_core/src/task_pool_options.rs | 9 +-- crates/bevy_diagnostic/Cargo.toml | 2 - crates/bevy_diagnostic/src/lib.rs | 13 ---- crates/bevy_diagnostic/src/system_profiler.rs | 71 ------------------- crates/bevy_dynamic_plugin/Cargo.toml | 1 - crates/bevy_dynamic_plugin/src/loader.rs | 1 - crates/bevy_ecs/Cargo.toml | 5 +- .../src/schedule/parallel_executor.rs | 25 ++----- crates/bevy_ecs/src/schedule/schedule.rs | 4 -- crates/bevy_ecs/src/system/commands.rs | 3 +- crates/bevy_ecs/src/system/mod.rs | 4 -- crates/bevy_ecs/src/system/profiler.rs | 25 ------- crates/bevy_gilrs/Cargo.toml | 4 +- crates/bevy_gilrs/src/lib.rs | 3 +- crates/bevy_internal/Cargo.toml | 3 +- crates/bevy_internal/src/default_plugins.rs | 1 + crates/bevy_internal/src/lib.rs | 5 ++ crates/bevy_internal/src/prelude.rs | 5 +- crates/bevy_log/Cargo.toml | 25 +++++++ crates/bevy_log/src/lib.rs | 56 +++++++++++++++ crates/bevy_render/Cargo.toml | 1 - .../src/render_graph/nodes/pass_node.rs | 5 +- crates/bevy_transform/Cargo.toml | 1 - .../bevy_transform/src/hierarchy/hierarchy.rs | 3 +- .../hierarchy/hierarchy_maintenance_system.rs | 20 ------ .../src/transform_propagate_system.rs | 2 - crates/bevy_utils/Cargo.toml | 1 + crates/bevy_utils/src/lib.rs | 1 + crates/bevy_wgpu/Cargo.toml | 1 - .../renderer/wgpu_render_resource_context.rs | 5 +- crates/bevy_wgpu/src/wgpu_render_pass.rs | 3 +- crates/bevy_winit/Cargo.toml | 1 - crates/bevy_winit/src/lib.rs | 3 +- docs/cargo_features.md | 8 ++- examples/app/tracing.rs | 49 ------------- examples/wasm/assets_wasm.rs | 11 +-- examples/wasm/headless_wasm.rs | 15 ++-- examples/wasm/hello_wasm.rs | 18 ++--- examples/wasm/winit_wasm.rs | 30 +++----- 46 files changed, 158 insertions(+), 315 deletions(-) delete mode 100644 crates/bevy_diagnostic/src/system_profiler.rs delete mode 100644 crates/bevy_ecs/src/system/profiler.rs create mode 100644 crates/bevy_log/Cargo.toml create mode 100644 crates/bevy_log/src/lib.rs delete mode 100644 examples/app/tracing.rs diff --git a/Cargo.toml b/Cargo.toml index 5e36929ee9d2b2..9c1d2702cbc6e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,7 @@ bevy_gltf = ["bevy_internal/bevy_gltf"] bevy_wgpu = ["bevy_internal/bevy_wgpu"] bevy_winit = ["bevy_internal/bevy_winit"] -profiler = ["bevy_internal/profiler"] +trace_chrome = ["bevy_internal/trace_chrome"] trace = ["bevy_internal/trace"] wgpu_trace = ["bevy_internal/wgpu_trace"] @@ -74,23 +74,15 @@ bevy_internal = {path = "crates/bevy_internal", version = "0.3.0", default-featu [dev-dependencies] anyhow = "1.0" -log = "0.4" rand = "0.7.3" ron = "0.6" serde = {version = "1", features = ["derive"]} -tracing = "0.1.21" -tracing-chrome = "0.2.0" -tracing-subscriber = "0.2.15" # bevy (Android) [target.'cfg(target_os = "android")'.dependencies] android_logger = "0.9" ndk-glue = {version = "0.2", features = ["logger"]} -[target.'cfg(target_arch = "wasm32")'.dev-dependencies] -console_error_panic_hook = "0.1.6" -console_log = {version = "0.2", features = ["color"]} - [[example]] name = "hello_world" path = "examples/hello_world.rs" @@ -171,10 +163,6 @@ path = "examples/app/return_after_run.rs" name = "thread_pool_resources" path = "examples/app/thread_pool_resources.rs" -[[example]] -name = "tracing" -path = "examples/app/tracing.rs" - [[example]] name = "hot_asset_reloading" path = "examples/asset/hot_asset_reloading.rs" diff --git a/crates/bevy_app/Cargo.toml b/crates/bevy_app/Cargo.toml index d4838ae7930842..a26bc27ac6bdf9 100644 --- a/crates/bevy_app/Cargo.toml +++ b/crates/bevy_app/Cargo.toml @@ -13,7 +13,7 @@ license = "MIT" keywords = ["bevy"] [features] -trace = [ "tracing" ] +trace = [] [dependencies] # bevy @@ -22,9 +22,7 @@ bevy_ecs = { path = "../bevy_ecs", version = "0.3.0" } bevy_utils = { path = "../bevy_utils", version = "0.3.0" } # other -log = { version = "0.4", features = ["release_max_level_info"] } serde = { version = "1.0", features = ["derive"] } -tracing = { version = "0.1.21", optional = true } [target.'cfg(target_arch = "wasm32")'.dependencies] wasm-bindgen = { version = "0.2" } diff --git a/crates/bevy_app/src/app.rs b/crates/bevy_app/src/app.rs index e0764fe2a54178..61d447fd286f2b 100644 --- a/crates/bevy_app/src/app.rs +++ b/crates/bevy_app/src/app.rs @@ -1,7 +1,7 @@ use crate::app_builder::AppBuilder; use bevy_ecs::{ParallelExecutor, Resources, Schedule, World}; #[cfg(feature = "trace")] -use tracing::info_span; +use bevy_utils::tracing::info_span; #[allow(clippy::needless_doctest_main)] /// Containers of app logic and data diff --git a/crates/bevy_app/src/app_builder.rs b/crates/bevy_app/src/app_builder.rs index 4c1bbfeb358d08..10113f5f69f657 100644 --- a/crates/bevy_app/src/app_builder.rs +++ b/crates/bevy_app/src/app_builder.rs @@ -5,6 +5,7 @@ use crate::{ stage, startup_stage, PluginGroup, PluginGroupBuilder, }; use bevy_ecs::{FromResources, IntoSystem, Resources, System, World}; +use bevy_utils::tracing::debug; /// Configure [App]s using the builder pattern pub struct AppBuilder { @@ -267,7 +268,7 @@ impl AppBuilder { where T: Plugin, { - log::debug!("added plugin: {}", plugin.name()); + debug!("added plugin: {}", plugin.name()); plugin.build(self); self } diff --git a/crates/bevy_app/src/plugin_group.rs b/crates/bevy_app/src/plugin_group.rs index 81be87a4864b32..3fadf24c40fe3f 100644 --- a/crates/bevy_app/src/plugin_group.rs +++ b/crates/bevy_app/src/plugin_group.rs @@ -1,5 +1,5 @@ use crate::{AppBuilder, Plugin}; -use bevy_utils::HashMap; +use bevy_utils::{tracing::debug, HashMap}; use std::any::TypeId; pub trait PluginGroup { @@ -94,7 +94,7 @@ impl PluginGroupBuilder { for ty in self.order.iter() { if let Some(entry) = self.plugins.get(ty) { if entry.enabled { - log::debug!("added plugin: {}", entry.plugin.name()); + debug!("added plugin: {}", entry.plugin.name()); entry.plugin.build(app); } } diff --git a/crates/bevy_asset/Cargo.toml b/crates/bevy_asset/Cargo.toml index 95a83a28814062..d0ef595e9434d2 100644 --- a/crates/bevy_asset/Cargo.toml +++ b/crates/bevy_asset/Cargo.toml @@ -33,7 +33,6 @@ crossbeam-channel = "0.4.4" anyhow = "1.0" thiserror = "1.0" downcast-rs = "1.2.0" -log = { version = "0.4", features = ["release_max_level_info"] } notify = { version = "5.0.0-pre.2", optional = true } parking_lot = "0.11.0" rand = "0.7.3" diff --git a/crates/bevy_core/Cargo.toml b/crates/bevy_core/Cargo.toml index 3109ca2d09dc92..868a0d67fbd04a 100644 --- a/crates/bevy_core/Cargo.toml +++ b/crates/bevy_core/Cargo.toml @@ -23,7 +23,5 @@ bevy_math = { path = "../bevy_math", version = "0.3.0" } bevy_utils = { path = "../bevy_utils", version = "0.3.0" } bevy_tasks = { path = "../bevy_tasks", version = "0.3.0" } -log = { version = "0.4", features = ["release_max_level_info"] } - [target.'cfg(target_arch = "wasm32")'.dependencies] instant = { version = "0.1", features = ["wasm-bindgen"] } diff --git a/crates/bevy_core/src/task_pool_options.rs b/crates/bevy_core/src/task_pool_options.rs index 7f850f0ab33cea..30c6b3120fcaa0 100644 --- a/crates/bevy_core/src/task_pool_options.rs +++ b/crates/bevy_core/src/task_pool_options.rs @@ -1,5 +1,6 @@ use bevy_ecs::Resources; use bevy_tasks::{AsyncComputeTaskPool, ComputeTaskPool, IoTaskPool, TaskPoolBuilder}; +use bevy_utils::tracing::trace; /// Defines a simple way to determine how many threads to use given the number of remaining cores /// and number of total cores @@ -96,7 +97,7 @@ impl DefaultTaskPoolOptions { self.min_total_threads, self.max_total_threads, ); - log::trace!("Assigning {} cores to default task pools", total_threads); + trace!("Assigning {} cores to default task pools", total_threads); let mut remaining_threads = total_threads; @@ -106,7 +107,7 @@ impl DefaultTaskPoolOptions { .io .get_number_of_threads(remaining_threads, total_threads); - log::trace!("IO Threads: {}", io_threads); + trace!("IO Threads: {}", io_threads); remaining_threads = remaining_threads.saturating_sub(io_threads); resources.insert(IoTaskPool( @@ -123,7 +124,7 @@ impl DefaultTaskPoolOptions { .async_compute .get_number_of_threads(remaining_threads, total_threads); - log::trace!("Async Compute Threads: {}", async_compute_threads); + trace!("Async Compute Threads: {}", async_compute_threads); remaining_threads = remaining_threads.saturating_sub(async_compute_threads); resources.insert(AsyncComputeTaskPool( @@ -141,7 +142,7 @@ impl DefaultTaskPoolOptions { .compute .get_number_of_threads(remaining_threads, total_threads); - log::trace!("Compute Threads: {}", compute_threads); + trace!("Compute Threads: {}", compute_threads); resources.insert(ComputeTaskPool( TaskPoolBuilder::default() .num_threads(compute_threads) diff --git a/crates/bevy_diagnostic/Cargo.toml b/crates/bevy_diagnostic/Cargo.toml index a36b11d7b491f3..9096cbc1e6e250 100644 --- a/crates/bevy_diagnostic/Cargo.toml +++ b/crates/bevy_diagnostic/Cargo.toml @@ -12,8 +12,6 @@ repository = "https://github.com/bevyengine/bevy" license = "MIT" keywords = ["bevy"] -[features] -profiler = ["bevy_ecs/profiler"] [dependencies] # bevy diff --git a/crates/bevy_diagnostic/src/lib.rs b/crates/bevy_diagnostic/src/lib.rs index ce4b285887e825..d54c32663ca62c 100644 --- a/crates/bevy_diagnostic/src/lib.rs +++ b/crates/bevy_diagnostic/src/lib.rs @@ -1,8 +1,6 @@ mod diagnostic; mod frame_time_diagnostics_plugin; mod print_diagnostics_plugin; -#[cfg(feature = "profiler")] -mod system_profiler; pub use diagnostic::*; pub use frame_time_diagnostics_plugin::FrameTimeDiagnosticsPlugin; pub use print_diagnostics_plugin::PrintDiagnosticsPlugin; @@ -16,16 +14,5 @@ pub struct DiagnosticsPlugin; impl Plugin for DiagnosticsPlugin { fn build(&self, app: &mut AppBuilder) { app.init_resource::(); - #[cfg(feature = "profiler")] - { - use bevy_ecs::IntoSystem; - app.add_resource::>(Box::new( - system_profiler::SystemProfiler::default(), - )) - .add_system_to_stage( - bevy_app::stage::LAST, - system_profiler::profiler_diagnostic_system.system(), - ); - } } } diff --git a/crates/bevy_diagnostic/src/system_profiler.rs b/crates/bevy_diagnostic/src/system_profiler.rs deleted file mode 100644 index c87d5adbe12c17..00000000000000 --- a/crates/bevy_diagnostic/src/system_profiler.rs +++ /dev/null @@ -1,71 +0,0 @@ -use crate::{Diagnostic, DiagnosticId, Diagnostics}; -use bevy_ecs::{Profiler, Res, ResMut}; -use bevy_utils::HashMap; -use parking_lot::RwLock; -use std::{borrow::Cow, sync::Arc}; - -#[cfg(target_arch = "wasm32")] -use instant::Instant; -#[cfg(not(target_arch = "wasm32"))] -use std::time::Instant; - -#[derive(Debug)] -struct SystemRunInfo { - start: Instant, - stop: Instant, -} - -#[derive(Debug, Default)] -struct SystemProfiles { - diagnostic_id: DiagnosticId, - history: Vec, - current_start: Option, -} - -/// Profiles systems by recording their run duration as diagnostics. -#[derive(Debug, Default)] -pub struct SystemProfiler { - system_profiles: Arc, SystemProfiles>>>, -} - -impl Profiler for SystemProfiler { - fn start(&self, scope: Cow<'static, str>) { - let mut system_profiles = self.system_profiles.write(); - let profiles = system_profiles - .entry(scope.clone()) - .or_insert_with(SystemProfiles::default); - - profiles.current_start = Some(Instant::now()); - } - - fn stop(&self, scope: Cow<'static, str>) { - let now = Instant::now(); - let mut system_profiles = self.system_profiles.write(); - let profiles = system_profiles.get_mut(&scope).unwrap(); - if let Some(current_start) = profiles.current_start.take() { - profiles.history.push(SystemRunInfo { - start: current_start, - stop: now, - }); - } - } -} - -pub fn profiler_diagnostic_system( - mut diagnostics: ResMut, - system_profiler: Res>, -) { - let system_profiler = system_profiler.downcast_ref::().unwrap(); - let mut system_profiles = system_profiler.system_profiles.write(); - for (scope, profiles) in system_profiles.iter_mut() { - if diagnostics.get(profiles.diagnostic_id).is_none() { - diagnostics.add(Diagnostic::new(profiles.diagnostic_id, &scope, 20)) - } - for profile in profiles.history.drain(..) { - diagnostics.add_measurement( - profiles.diagnostic_id, - (profile.stop - profile.start).as_secs_f64(), - ); - } - } -} diff --git a/crates/bevy_dynamic_plugin/Cargo.toml b/crates/bevy_dynamic_plugin/Cargo.toml index 951031fd62d000..8a955022e52495 100644 --- a/crates/bevy_dynamic_plugin/Cargo.toml +++ b/crates/bevy_dynamic_plugin/Cargo.toml @@ -19,5 +19,4 @@ keywords = ["bevy"] bevy_app = { path = "../bevy_app", version = "0.3.0" } # other -log = { version = "0.4", features = ["release_max_level_info"] } libloading = { version = "0.6" } diff --git a/crates/bevy_dynamic_plugin/src/loader.rs b/crates/bevy_dynamic_plugin/src/loader.rs index 7d9670dfea7df4..73ffa0ce871ff4 100644 --- a/crates/bevy_dynamic_plugin/src/loader.rs +++ b/crates/bevy_dynamic_plugin/src/loader.rs @@ -20,7 +20,6 @@ pub trait DynamicPluginExt { impl DynamicPluginExt for AppBuilder { fn load_plugin(&mut self, path: &str) -> &mut Self { let (_lib, plugin) = dynamically_load_plugin(path); - log::debug!("loaded plugin: {}", plugin.name()); plugin.build(self); self } diff --git a/crates/bevy_ecs/Cargo.toml b/crates/bevy_ecs/Cargo.toml index 8fcc42d6b3d7fe..8707da006b095a 100644 --- a/crates/bevy_ecs/Cargo.toml +++ b/crates/bevy_ecs/Cargo.toml @@ -14,8 +14,7 @@ keywords = ["ecs", "game", "bevy"] categories = ["game-engines", "data-structures"] [features] -profiler = [] -trace = [ "tracing" ] +trace = [] [dependencies] bevy_hecs = { path = "hecs", features = ["macros", "serialize"], version = "0.3.0" } @@ -26,5 +25,3 @@ thiserror = "1.0" fixedbitset = "0.3.1" downcast-rs = "1.2.0" parking_lot = "0.11.0" -log = { version = "0.4", features = ["release_max_level_info"] } -tracing = { version = "0.1.21", optional = true } diff --git a/crates/bevy_ecs/src/schedule/parallel_executor.rs b/crates/bevy_ecs/src/schedule/parallel_executor.rs index 225ca8344f91ce..fa9aca958b5977 100644 --- a/crates/bevy_ecs/src/schedule/parallel_executor.rs +++ b/crates/bevy_ecs/src/schedule/parallel_executor.rs @@ -5,10 +5,11 @@ use crate::{ }; use bevy_hecs::{ArchetypesGeneration, TypeAccess, World}; use bevy_tasks::{ComputeTaskPool, CountdownEvent, TaskPool}; +#[cfg(feature = "trace")] +use bevy_utils::tracing::info_span; +use bevy_utils::tracing::trace; use fixedbitset::FixedBitSet; use std::ops::Range; -#[cfg(feature = "trace")] -use tracing::info_span; /// Executes each schedule stage in parallel by analyzing system dependencies. /// System execution order is undefined except under the following conditions: @@ -68,7 +69,6 @@ impl ParallelExecutor { let stage_span = info_span!("stage", name = stage_name.as_ref()); #[cfg(feature = "trace")] let _stage_guard = stage_span.enter(); - log::trace!("run stage {:?}", stage_name); if let Some(stage_systems) = schedule.stages.get_mut(stage_name) { executor_stage.run(world, resources, stage_systems, schedule_changed); } @@ -334,12 +334,12 @@ impl ExecutorStage { compute_pool: &TaskPool, ) { // Generate tasks for systems in the given range and block until they are complete - log::trace!("running systems {:?}", prepared_system_range); + trace!("running systems {:?}", prepared_system_range); compute_pool.scope(|scope| { let start_system_index = prepared_system_range.start; let mut system_index = start_system_index; for system in &mut systems[prepared_system_range] { - log::trace!( + trace!( "prepare {} {} with {} dependents and {} dependencies", system_index, system.name(), @@ -381,12 +381,6 @@ impl ExecutorStage { for (trigger_event, dependent_system_index) in trigger_events.iter().zip(dependent_systems) { - log::trace!( - " * system ({}) triggers events: ({}): {}", - system_index, - dependent_system_index, - trigger_event.get() - ); debug_assert!( *dependent_system_index < start_system_index || trigger_event.get() > 0 ); @@ -408,12 +402,7 @@ impl ExecutorStage { #[cfg(feature = "trace")] let _system_guard = system_span.enter(); - log::trace!("run {}", system.name()); - #[cfg(feature = "profiler")] - crate::profiler_start(resources, system.name().clone()); system.run(world_ref, resources_ref); - #[cfg(feature = "profiler")] - crate::profiler_stop(resources, system.name().clone()); } // Notify dependents that this task is done @@ -506,11 +495,10 @@ impl ExecutorStage { let system = systems[thread_local_system_index].as_mut(); #[cfg(feature = "trace")] - let system_span = info_span!("system", name = system.name().as_ref()); + let system_span = info_span!("thread_local_system", name = system.name().as_ref()); #[cfg(feature = "trace")] let _system_guard = system_span.enter(); - log::trace!("running thread local system {}", system.name()); system.run(world, resources); system.run_thread_local(world, resources); } @@ -527,7 +515,6 @@ impl ExecutorStage { next_thread_local_index, ); - log::trace!("running systems {:?}", run_ready_system_index_range); self.run_systems( world, resources, diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index fd710946f4a2c8..87339caaca36f2 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -148,8 +148,6 @@ impl Schedule { for stage_name in self.stage_order.iter() { if let Some(stage_systems) = self.stages.get_mut(stage_name) { for system in stage_systems.iter_mut() { - #[cfg(feature = "profiler")] - crate::profiler_start(resources, system.name().clone()); system.update(world); match system.thread_local_execution() { ThreadLocalExecution::NextFlush => system.run(world, resources), @@ -159,8 +157,6 @@ impl Schedule { system.run_thread_local(world, resources); } } - #[cfg(feature = "profiler")] - crate::profiler_stop(resources, system.name().clone()); } // "flush" diff --git a/crates/bevy_ecs/src/system/commands.rs b/crates/bevy_ecs/src/system/commands.rs index 849c7d20bbf0bc..95dbe93e854cef 100644 --- a/crates/bevy_ecs/src/system/commands.rs +++ b/crates/bevy_ecs/src/system/commands.rs @@ -1,6 +1,7 @@ use super::SystemId; use crate::resource::{Resource, Resources}; use bevy_hecs::{Bundle, Component, DynamicBundle, Entity, EntityReserver, World}; +use bevy_utils::tracing::debug; use std::marker::PhantomData; /// A [World] mutation @@ -51,7 +52,7 @@ pub(crate) struct Despawn { impl Command for Despawn { fn write(self: Box, world: &mut World, _resources: &mut Resources) { if let Err(e) = world.despawn(self.entity) { - log::debug!("Failed to despawn entity {:?}: {}", self.entity, e); + debug!("Failed to despawn entity {:?}: {}", self.entity, e); } } } diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index a1c7b001c49f69..85ecede4c33673 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -1,8 +1,6 @@ mod commands; mod into_system; mod into_thread_local; -#[cfg(feature = "profiler")] -mod profiler; mod query; #[allow(clippy::module_inception)] mod system; @@ -11,8 +9,6 @@ mod system_param; pub use commands::*; pub use into_system::*; pub use into_thread_local::*; -#[cfg(feature = "profiler")] -pub use profiler::*; pub use query::*; pub use system::*; pub use system_param::*; diff --git a/crates/bevy_ecs/src/system/profiler.rs b/crates/bevy_ecs/src/system/profiler.rs deleted file mode 100644 index 04914bde3735fb..00000000000000 --- a/crates/bevy_ecs/src/system/profiler.rs +++ /dev/null @@ -1,25 +0,0 @@ -use crate::Resources; -use downcast_rs::{impl_downcast, Downcast}; -use std::borrow::Cow; - -/// Runs at the start and end of each system -/// -/// Profilers are used to collect diagnostics about system execution. -pub trait Profiler: Downcast + Send + Sync + 'static { - fn start(&self, scope: Cow<'static, str>); - fn stop(&self, scope: Cow<'static, str>); -} - -pub fn profiler_start(resources: &Resources, scope: Cow<'static, str>) { - if let Some(profiler) = resources.get::>() { - profiler.start(scope); - } -} - -pub fn profiler_stop(resources: &Resources, scope: Cow<'static, str>) { - if let Some(profiler) = resources.get::>() { - profiler.stop(scope); - } -} - -impl_downcast!(Profiler); diff --git a/crates/bevy_gilrs/Cargo.toml b/crates/bevy_gilrs/Cargo.toml index dbf7e09a5bf4f4..4adb09b0278c75 100644 --- a/crates/bevy_gilrs/Cargo.toml +++ b/crates/bevy_gilrs/Cargo.toml @@ -14,7 +14,7 @@ keywords = ["bevy"] bevy_app = { path = "../bevy_app", version = "0.3.0" } bevy_ecs = { path = "../bevy_ecs", version = "0.3.0" } bevy_input = { path = "../bevy_input", version = "0.3.0" } +bevy_utils = { path = "../bevy_utils", version = "0.3.0" } # other -gilrs = "0.8.0" -log = { version = "0.4", features = ["release_max_level_info"] } \ No newline at end of file +gilrs = "0.8.0" \ No newline at end of file diff --git a/crates/bevy_gilrs/src/lib.rs b/crates/bevy_gilrs/src/lib.rs index cc0113c09fd3b1..3e3a0d5b99b25d 100644 --- a/crates/bevy_gilrs/src/lib.rs +++ b/crates/bevy_gilrs/src/lib.rs @@ -3,6 +3,7 @@ mod gilrs_system; use bevy_app::{prelude::*, startup_stage::PRE_STARTUP}; use bevy_ecs::prelude::*; +use bevy_utils::tracing::error; use gilrs::GilrsBuilder; use gilrs_system::{gilrs_event_startup_system, gilrs_event_system}; @@ -27,7 +28,7 @@ impl Plugin for GilrsPlugin { gilrs_event_system.thread_local_system(), ); } - Err(err) => log::error!("Failed to start Gilrs. {}", err), + Err(err) => error!("Failed to start Gilrs. {}", err), } } } diff --git a/crates/bevy_internal/Cargo.toml b/crates/bevy_internal/Cargo.toml index 23fdc7de6151f1..4ceb24261e7fb0 100644 --- a/crates/bevy_internal/Cargo.toml +++ b/crates/bevy_internal/Cargo.toml @@ -14,9 +14,9 @@ keywords = ["game", "engine", "gamedev", "graphics", "bevy"] categories = ["game-engines", "graphics", "gui", "rendering"] [features] -profiler = ["bevy_ecs/profiler", "bevy_diagnostic/profiler"] wgpu_trace = ["bevy_wgpu/trace"] trace = [ "bevy_app/trace", "bevy_ecs/trace" ] +trace_chrome = [ "bevy_log/tracing-chrome" ] # Image format support for texture loading (PNG and HDR are enabled by default) hdr = ["bevy_render/hdr"] @@ -43,6 +43,7 @@ bevy_core = { path = "../bevy_core", version = "0.3.0" } bevy_diagnostic = { path = "../bevy_diagnostic", version = "0.3.0" } bevy_ecs = { path = "../bevy_ecs", version = "0.3.0" } bevy_input = { path = "../bevy_input", version = "0.3.0" } +bevy_log = { path = "../bevy_log", version = "0.3.0" } bevy_math = { path = "../bevy_math", version = "0.3.0" } bevy_property = { path = "../bevy_property", version = "0.3.0" } bevy_scene = { path = "../bevy_scene", version = "0.3.0" } diff --git a/crates/bevy_internal/src/default_plugins.rs b/crates/bevy_internal/src/default_plugins.rs index 1e132aaec74202..0af6f824ae5838 100644 --- a/crates/bevy_internal/src/default_plugins.rs +++ b/crates/bevy_internal/src/default_plugins.rs @@ -4,6 +4,7 @@ pub struct DefaultPlugins; impl PluginGroup for DefaultPlugins { fn build(&mut self, group: &mut PluginGroupBuilder) { + group.add(bevy_log::LogPlugin::default()); group.add(bevy_type_registry::TypeRegistryPlugin::default()); group.add(bevy_core::CorePlugin::default()); group.add(bevy_transform::TransformPlugin::default()); diff --git a/crates/bevy_internal/src/lib.rs b/crates/bevy_internal/src/lib.rs index 0872432f551259..e3e9a6721542b7 100644 --- a/crates/bevy_internal/src/lib.rs +++ b/crates/bevy_internal/src/lib.rs @@ -34,6 +34,11 @@ pub mod input { pub use bevy_input::*; } +pub mod log { + //! Logging capabilities + pub use bevy_log::*; +} + pub mod math { //! Math types (Vec3, Mat4, Quat, etc) and helpers. pub use bevy_math::*; diff --git a/crates/bevy_internal/src/prelude.rs b/crates/bevy_internal/src/prelude.rs index 4e2b911232435a..266fcc20e1c055 100644 --- a/crates/bevy_internal/src/prelude.rs +++ b/crates/bevy_internal/src/prelude.rs @@ -1,7 +1,8 @@ pub use crate::{ app::prelude::*, asset::prelude::*, core::prelude::*, ecs::prelude::*, input::prelude::*, - math::prelude::*, property::prelude::*, scene::prelude::*, transform::prelude::*, - type_registry::RegisterType, window::prelude::*, DefaultPlugins, MinimalPlugins, + log::prelude::*, math::prelude::*, property::prelude::*, scene::prelude::*, + transform::prelude::*, type_registry::RegisterType, window::prelude::*, DefaultPlugins, + MinimalPlugins, }; #[cfg(feature = "bevy_audio")] diff --git a/crates/bevy_log/Cargo.toml b/crates/bevy_log/Cargo.toml new file mode 100644 index 00000000000000..8b06430597c1e6 --- /dev/null +++ b/crates/bevy_log/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "bevy_log" +version = "0.3.0" +edition = "2018" +authors = [ + "Bevy Contributors ", + "Carter Anderson ", +] +description = "Provides logging for Bevy Engine" +homepage = "https://bevyengine.org" +repository = "https://github.com/bevyengine/bevy" +license = "MIT" +keywords = ["bevy"] + + +[dependencies] +bevy_app = { path = "../bevy_app", version = "0.3.0" } +bevy_utils = { path = "../bevy_utils", version = "0.3.0" } + +tracing-subscriber = "0.2.15" +tracing-chrome = { git = "https://github.com/superdump/tracing-chrome", branch = "name.fields", optional = true} + +[target.'cfg(target_arch = "wasm32")'.dependencies] +console_error_panic_hook = "0.1.6" +tracing-wasm = "0.1" \ No newline at end of file diff --git a/crates/bevy_log/src/lib.rs b/crates/bevy_log/src/lib.rs new file mode 100644 index 00000000000000..5526110b5c5762 --- /dev/null +++ b/crates/bevy_log/src/lib.rs @@ -0,0 +1,56 @@ +pub mod prelude { + pub use bevy_app::{AppBuilder, Plugin}; + pub use bevy_utils::tracing::*; +} +pub use bevy_app::{AppBuilder, Plugin}; +pub use bevy_utils::tracing::*; +#[cfg(all(not(target_arch = "wasm32"), not(target_os = "android")))] +use tracing_subscriber::{fmt, prelude::*, registry::Registry, EnvFilter}; + +/// Adds logging to Apps. +#[derive(Default)] +pub struct LogPlugin; + +impl Plugin for LogPlugin { + fn build(&self, _app: &mut AppBuilder) { + #[cfg(all(not(target_arch = "wasm32"), not(target_os = "android")))] + setup_default(_app); + #[cfg(target_arch = "wasm32")] + setup_wasm(); + #[cfg(target_arch = "android")] + setup_android(); + } +} + +#[cfg(all(not(target_arch = "wasm32"), not(target_os = "android")))] +fn setup_default(_app: &mut AppBuilder) { + let fmt_layer = fmt::Layer::default(); + let filter_layer = EnvFilter::try_from_default_env() + .or_else(|_| EnvFilter::try_new("info,wgpu=warn")) + .unwrap(); + + let subscriber = Registry::default().with(filter_layer).with(fmt_layer); + #[cfg(feature = "tracing-chrome")] + { + let (chrome_layer, guard) = tracing_chrome::ChromeLayerBuilder::new().build(); + _app.resources_mut().insert_thread_local(guard); + let subscriber = subscriber.with(chrome_layer); + bevy_utils::tracing::subscriber::set_global_default(subscriber) + .expect("Could not set global default tracing subscriber"); + } + + #[cfg(not(feature = "tracing-chrome"))] + { + bevy_utils::tracing::subscriber::set_global_default(subscriber) + .expect("Could not set global default tracing subscriber"); + } +} + +#[cfg(target_arch = "wasm32")] +fn setup_wasm() { + console_error_panic_hook::set_once(); + tracing_wasm::set_as_global_default(); +} + +#[cfg(target_os = "android")] +fn setup_android() {} diff --git a/crates/bevy_render/Cargo.toml b/crates/bevy_render/Cargo.toml index b357fd5de9b078..a2b951cf4a55a8 100644 --- a/crates/bevy_render/Cargo.toml +++ b/crates/bevy_render/Cargo.toml @@ -30,7 +30,6 @@ bevy_utils = { path = "../bevy_utils", version = "0.3.0" } image = { version = "0.23", default-features = false } # misc -log = { version = "0.4", features = ["release_max_level_info"] } uuid = { version = "0.8", features = ["v4", "serde"] } serde = { version = "1", features = ["derive"] } bitflags = "1.2.1" diff --git a/crates/bevy_render/src/render_graph/nodes/pass_node.rs b/crates/bevy_render/src/render_graph/nodes/pass_node.rs index 4492b305643e34..aefe11f92b062e 100644 --- a/crates/bevy_render/src/render_graph/nodes/pass_node.rs +++ b/crates/bevy_render/src/render_graph/nodes/pass_node.rs @@ -13,6 +13,7 @@ use crate::{ }; use bevy_asset::{Assets, Handle}; use bevy_ecs::{HecsQuery, ReadOnlyFetch, Resources, World}; +use bevy_utils::tracing::debug; use std::{fmt, marker::PhantomData, ops::Deref}; #[derive(Debug)] @@ -274,14 +275,14 @@ where instances.clone(), ); } else { - log::info!("Could not draw indexed because the pipeline layout wasn't fully set for pipeline: {:?}", draw_state.pipeline); + debug!("Could not draw indexed because the pipeline layout wasn't fully set for pipeline: {:?}", draw_state.pipeline); } } RenderCommand::Draw { vertices, instances } => { if draw_state.can_draw() { render_pass.draw(vertices.clone(), instances.clone()); } else { - log::info!("Could not draw because the pipeline layout wasn't fully set for pipeline: {:?}", draw_state.pipeline); + debug!("Could not draw because the pipeline layout wasn't fully set for pipeline: {:?}", draw_state.pipeline); } } RenderCommand::SetVertexBuffer { diff --git a/crates/bevy_transform/Cargo.toml b/crates/bevy_transform/Cargo.toml index 22e530ffed04c6..eddd4e69f8ac3c 100644 --- a/crates/bevy_transform/Cargo.toml +++ b/crates/bevy_transform/Cargo.toml @@ -22,5 +22,4 @@ bevy_type_registry = { path = "../bevy_type_registry", version = "0.3.0" } bevy_utils = { path = "../bevy_utils", version = "0.3.0" } # other -log = "0.4" smallvec = { version = "1.4", features = ["serde"] } diff --git a/crates/bevy_transform/src/hierarchy/hierarchy.rs b/crates/bevy_transform/src/hierarchy/hierarchy.rs index d15780ec96058d..6509fa0ff7a0de 100644 --- a/crates/bevy_transform/src/hierarchy/hierarchy.rs +++ b/crates/bevy_transform/src/hierarchy/hierarchy.rs @@ -1,5 +1,6 @@ use crate::components::{Children, Parent}; use bevy_ecs::{Command, Commands, Entity, Query, Resources, World}; +use bevy_utils::tracing::debug; pub fn run_on_hierarchy( children_query: &Query<&Children>, @@ -62,7 +63,7 @@ fn despawn_with_children_recursive_inner(world: &mut World, entity: Entity) { } if let Err(e) = world.despawn(entity) { - log::debug!("Failed to despawn entity {:?}: {}", entity, e); + debug!("Failed to despawn entity {:?}: {}", entity, e); } } diff --git a/crates/bevy_transform/src/hierarchy/hierarchy_maintenance_system.rs b/crates/bevy_transform/src/hierarchy/hierarchy_maintenance_system.rs index b7e4c069d79171..e7fccb1f1834e2 100644 --- a/crates/bevy_transform/src/hierarchy/hierarchy_maintenance_system.rs +++ b/crates/bevy_transform/src/hierarchy/hierarchy_maintenance_system.rs @@ -13,9 +13,7 @@ pub fn parent_update_system( // Entities with a missing `Parent` (ie. ones that have a `PreviousParent`), remove // them from the `Children` of the `PreviousParent`. for (entity, previous_parent) in removed_parent_query.iter() { - log::trace!("Parent was removed from {:?}", entity); if let Ok(mut previous_parent_children) = children_query.get_mut(previous_parent.0) { - log::trace!(" > Removing {:?} from it's prev parent's children", entity); previous_parent_children.0.retain(|e| *e != entity); commands.remove_one::(entity); } @@ -26,43 +24,30 @@ pub fn parent_update_system( // Entities with a changed Parent (that also have a PreviousParent, even if None) for (entity, parent, possible_previous_parent) in changed_parent_query.iter_mut() { - log::trace!("Parent changed for {:?}", entity); if let Some(mut previous_parent) = possible_previous_parent { // New and previous point to the same Entity, carry on, nothing to see here. if previous_parent.0 == parent.0 { - log::trace!(" > But the previous parent is the same, ignoring..."); continue; } // Remove from `PreviousParent.Children`. if let Ok(mut previous_parent_children) = children_query.get_mut(previous_parent.0) { - log::trace!(" > Removing {:?} from prev parent's children", entity); (*previous_parent_children).0.retain(|e| *e != entity); } // Set `PreviousParent = Parent`. *previous_parent = PreviousParent(parent.0); } else { - log::trace!("Adding missing PreviousParent to {:?}", entity); commands.insert_one(entity, PreviousParent(parent.0)); }; // Add to the parent's `Children` (either the real component, or // `children_additions`). - log::trace!("Adding {:?} to it's new parent {:?}", entity, parent.0); if let Ok(mut new_parent_children) = children_query.get_mut(parent.0) { // This is the parent - log::trace!( - " > The new parent {:?} already has a `Children`, adding to it.", - parent.0 - ); (*new_parent_children).0.push(entity); } else { // The parent doesn't have a children entity, lets add it - log::trace!( - "The new parent {:?} doesn't yet have `Children` component.", - parent.0 - ); children_additions .entry(parent.0) .or_insert_with(Default::default) @@ -74,11 +59,6 @@ pub fn parent_update_system( // collect multiple new children that point to the same parent into the same // SmallVec, and to prevent redundant add+remove operations. children_additions.iter().for_each(|(k, v)| { - log::trace!( - "Flushing: Entity {:?} adding `Children` component {:?}", - k, - v - ); commands.insert_one(*k, Children::with(v)); }); } diff --git a/crates/bevy_transform/src/transform_propagate_system.rs b/crates/bevy_transform/src/transform_propagate_system.rs index 4727b24528f0d0..2eda285b2604e5 100644 --- a/crates/bevy_transform/src/transform_propagate_system.rs +++ b/crates/bevy_transform/src/transform_propagate_system.rs @@ -33,8 +33,6 @@ fn propagate_recursive( children_query: &Query>>>, entity: Entity, ) { - log::trace!("Updating Transform for {:?}", entity); - let global_matrix = { if let Ok((transform, mut global_transform)) = transform_query.get_mut(entity) { *global_transform = parent.mul_transform(*transform); diff --git a/crates/bevy_utils/Cargo.toml b/crates/bevy_utils/Cargo.toml index e6e30e5e79202f..50714ad10b61fb 100644 --- a/crates/bevy_utils/Cargo.toml +++ b/crates/bevy_utils/Cargo.toml @@ -14,6 +14,7 @@ keywords = ["bevy"] [dependencies] ahash = "0.5.3" +tracing = {version = "0.1", features = ["release_max_level_info"]} [target.'cfg(target_arch = "wasm32")'.dependencies] getrandom = {version = "0.2.0", features = ["js"]} diff --git a/crates/bevy_utils/src/lib.rs b/crates/bevy_utils/src/lib.rs index 76492cb010ce44..c4990d1d6afdad 100644 --- a/crates/bevy_utils/src/lib.rs +++ b/crates/bevy_utils/src/lib.rs @@ -2,6 +2,7 @@ use ahash::RandomState; use std::{future::Future, pin::Pin}; pub use ahash::AHasher; +pub use tracing; #[cfg(not(target_arch = "wasm32"))] pub type BoxedFuture<'a, T> = Pin + Send + 'a>>; diff --git a/crates/bevy_wgpu/Cargo.toml b/crates/bevy_wgpu/Cargo.toml index c2deb9cd339df4..aa96a3d8c21cff 100644 --- a/crates/bevy_wgpu/Cargo.toml +++ b/crates/bevy_wgpu/Cargo.toml @@ -31,7 +31,6 @@ bevy_utils = { path = "../bevy_utils", version = "0.3.0" } # other wgpu = "0.6" futures-lite = "1.4.0" -log = { version = "0.4", features = ["release_max_level_info"] } crossbeam-channel = "0.4.4" crossbeam-utils = "0.7.2" parking_lot = "0.11.0" diff --git a/crates/bevy_wgpu/src/renderer/wgpu_render_resource_context.rs b/crates/bevy_wgpu/src/renderer/wgpu_render_resource_context.rs index ab5048da4a033a..cda3fce66fe9b5 100644 --- a/crates/bevy_wgpu/src/renderer/wgpu_render_resource_context.rs +++ b/crates/bevy_wgpu/src/renderer/wgpu_render_resource_context.rs @@ -15,6 +15,7 @@ use bevy_render::{ shader::Shader, texture::{Extent3d, SamplerDescriptor, TextureDescriptor}, }; +use bevy_utils::tracing::trace; use bevy_window::{Window, WindowId}; use futures_lite::future; use std::{borrow::Cow, ops::Range, sync::Arc}; @@ -456,7 +457,7 @@ impl RenderResourceContext for WgpuRenderResourceContext { .resources .has_bind_group(bind_group_descriptor_id, bind_group.id) { - log::trace!( + trace!( "start creating bind group for RenderResourceSet {:?}", bind_group.id ); @@ -507,7 +508,7 @@ impl RenderResourceContext for WgpuRenderResourceContext { bind_group_info .bind_groups .insert(bind_group.id, wgpu_bind_group); - log::trace!( + trace!( "created bind group for RenderResourceSet {:?}", bind_group.id ); diff --git a/crates/bevy_wgpu/src/wgpu_render_pass.rs b/crates/bevy_wgpu/src/wgpu_render_pass.rs index 6aa59b7f3415a1..ee94b0189986c0 100644 --- a/crates/bevy_wgpu/src/wgpu_render_pass.rs +++ b/crates/bevy_wgpu/src/wgpu_render_pass.rs @@ -5,6 +5,7 @@ use bevy_render::{ pipeline::{BindGroupDescriptorId, PipelineDescriptor}, renderer::{BindGroupId, BufferId, RenderContext}, }; +use bevy_utils::tracing::trace; use std::ops::Range; #[derive(Debug)] @@ -74,7 +75,7 @@ impl<'a> RenderPass for WgpuRenderPass<'a> { EMPTY }; - log::trace!( + trace!( "set bind group {:?} {:?}: {:?}", bind_group_descriptor_id, dynamic_uniform_indices, diff --git a/crates/bevy_winit/Cargo.toml b/crates/bevy_winit/Cargo.toml index 7e25cf4f9e3945..7403b52396189d 100644 --- a/crates/bevy_winit/Cargo.toml +++ b/crates/bevy_winit/Cargo.toml @@ -27,7 +27,6 @@ bevy_utils = { path = "../bevy_utils", version = "0.3.0" } # other winit = { version = "0.23.0", default-features = false } -log = { version = "0.4", features = ["release_max_level_info"] } [target.'cfg(target_arch = "wasm32")'.dependencies] winit = { version = "0.23.0", features = ["web-sys"], default-features = false } diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index 36eae8170d04c9..484e8796450c7c 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -12,6 +12,7 @@ pub use winit_windows::*; use bevy_app::{prelude::*, AppExit}; use bevy_ecs::{IntoThreadLocalSystem, Resources, World}; use bevy_math::Vec2; +use bevy_utils::tracing::trace; use bevy_window::{ CreateWindow, CursorMoved, ReceivedCharacter, Window, WindowCloseRequested, WindowCreated, WindowResized, Windows, @@ -160,7 +161,7 @@ pub fn winit_runner(mut app: App) { app.initialize(); - log::debug!("Entering winit event loop"); + trace!("Entering winit event loop"); let should_return_from_run = app .resources diff --git a/docs/cargo_features.md b/docs/cargo_features.md index d00e594ce02a86..7dfacc54e35942 100644 --- a/docs/cargo_features.md +++ b/docs/cargo_features.md @@ -44,9 +44,13 @@ Make GUI applications use X11 protocol. You could enable wayland feature to over ## Optional Features -### profiler +### trace -For profiler. +Enables system tracing (useful in tandem wit a feature like trace_chrome) + +### trace_chrome + +Enables [tracing-chrome](https://github.com/thoren-d/tracing-chrome) as bevy_log output. This allows you to visualize system execution. ### wgpu_trace diff --git a/examples/app/tracing.rs b/examples/app/tracing.rs deleted file mode 100644 index dbbd725a8f1b47..00000000000000 --- a/examples/app/tracing.rs +++ /dev/null @@ -1,49 +0,0 @@ -use bevy::{input::system::exit_on_esc_system, prelude::*}; -use std::{thread, time}; -use tracing::info; -use tracing_chrome::ChromeLayerBuilder; -use tracing_subscriber::{fmt, prelude::*, registry::Registry, EnvFilter}; - -pub fn setup_global_subscriber() -> impl Drop { - let fmt_layer = fmt::Layer::default(); - let filter_layer = EnvFilter::try_from_default_env() - .or_else(|_| EnvFilter::try_new("info,wgpu=warn")) - .unwrap(); - - let (chrome_layer, _guard) = ChromeLayerBuilder::new().build(); - - let subscriber = Registry::default() - .with(filter_layer) - .with(fmt_layer) - .with(chrome_layer); - - tracing::subscriber::set_global_default(subscriber).expect("Could not set global default"); - _guard -} - -fn main() { - let _guard = setup_global_subscriber(); - - App::build() - .add_plugins(DefaultPlugins) - .add_startup_system(a_system.system()) - .add_system(foo_bar_baz.system()) - .add_system(exit_on_esc_system.system()) - .run(); -} - -fn a_system(commands: &mut Commands) { - let ten_millis = time::Duration::from_millis(10); - thread::sleep(ten_millis); - - commands.spawn((GlobalTransform::default(), Transform::default())); -} - -fn foo_bar_baz(query: Query<&Transform>) { - for transform in query.iter() { - let five_millis = time::Duration::from_millis(5); - thread::sleep(five_millis); - - info!(?transform); - } -} diff --git a/examples/wasm/assets_wasm.rs b/examples/wasm/assets_wasm.rs index b088a97c3eb219..e9742b513b841a 100644 --- a/examples/wasm/assets_wasm.rs +++ b/examples/wasm/assets_wasm.rs @@ -1,6 +1,3 @@ -#[cfg(target_arch = "wasm32")] -extern crate console_error_panic_hook; - use bevy::{ asset::{AssetLoader, AssetServerSettings, LoadContext, LoadedAsset}, prelude::*, @@ -9,12 +6,6 @@ use bevy::{ }; fn main() { - #[cfg(target_arch = "wasm32")] - { - std::panic::set_hook(Box::new(console_error_panic_hook::hook)); - console_log::init_with_level(log::Level::Debug).expect("cannot initialize console_log"); - } - App::build() .add_resource(AssetServerSettings { asset_folder: "/".to_string(), @@ -45,7 +36,7 @@ fn print_asset(mut state: ResMut, rust_sources: Res) { if state.count % 60 == 0 { - log::info!("counter system: {}", state.count); + info!("counter system: {}", state.count); } state.count += 1; } diff --git a/examples/wasm/hello_wasm.rs b/examples/wasm/hello_wasm.rs index ff4fbebeb94626..c3fbef4bdaa845 100644 --- a/examples/wasm/hello_wasm.rs +++ b/examples/wasm/hello_wasm.rs @@ -1,18 +1,12 @@ -#[cfg(target_arch = "wasm32")] -extern crate console_error_panic_hook; - -use bevy::prelude::*; +use bevy::{log::LogPlugin, prelude::*}; fn main() { - #[cfg(target_arch = "wasm32")] - { - std::panic::set_hook(Box::new(console_error_panic_hook::hook)); - console_log::init_with_level(log::Level::Debug).expect("cannot initialize console_log"); - } - - App::build().add_system(hello_wasm_system.system()).run(); + App::build() + .add_plugin(LogPlugin::default()) + .add_system(hello_wasm_system.system()) + .run(); } fn hello_wasm_system() { - log::info!("hello wasm"); + info!("hello wasm"); } diff --git a/examples/wasm/winit_wasm.rs b/examples/wasm/winit_wasm.rs index 28a532ec8a3be4..bf73c081ec5c9a 100644 --- a/examples/wasm/winit_wasm.rs +++ b/examples/wasm/winit_wasm.rs @@ -1,6 +1,3 @@ -#[cfg(target_arch = "wasm32")] -extern crate console_error_panic_hook; - use bevy::{ input::{ keyboard::KeyboardInput, @@ -10,12 +7,6 @@ use bevy::{ }; fn main() { - #[cfg(target_arch = "wasm32")] - { - std::panic::set_hook(Box::new(console_error_panic_hook::hook)); - console_log::init_with_level(log::Level::Debug).expect("cannot initialize console_log"); - } - App::build() .add_resource(WindowDescriptor { width: 300, @@ -34,12 +25,12 @@ fn main() { } fn hello_wasm_system() { - log::info!("hello wasm"); + info!("hello wasm"); } fn counter(mut state: Local, time: Res