Skip to content

Commit 7b67583

Browse files
committed
add bevy_log crate
1 parent a266578 commit 7b67583

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+158
-315
lines changed

Cargo.toml

+1-13
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ bevy_gltf = ["bevy_internal/bevy_gltf"]
4848
bevy_wgpu = ["bevy_internal/bevy_wgpu"]
4949
bevy_winit = ["bevy_internal/bevy_winit"]
5050

51-
profiler = ["bevy_internal/profiler"]
51+
trace_chrome = ["bevy_internal/trace_chrome"]
5252
trace = ["bevy_internal/trace"]
5353
wgpu_trace = ["bevy_internal/wgpu_trace"]
5454

@@ -74,23 +74,15 @@ bevy_internal = {path = "crates/bevy_internal", version = "0.3.0", default-featu
7474

7575
[dev-dependencies]
7676
anyhow = "1.0"
77-
log = "0.4"
7877
rand = "0.7.3"
7978
ron = "0.6"
8079
serde = {version = "1", features = ["derive"]}
81-
tracing = "0.1.21"
82-
tracing-chrome = "0.2.0"
83-
tracing-subscriber = "0.2.15"
8480

8581
# bevy (Android)
8682
[target.'cfg(target_os = "android")'.dependencies]
8783
android_logger = "0.9"
8884
ndk-glue = {version = "0.2", features = ["logger"]}
8985

90-
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
91-
console_error_panic_hook = "0.1.6"
92-
console_log = {version = "0.2", features = ["color"]}
93-
9486
[[example]]
9587
name = "hello_world"
9688
path = "examples/hello_world.rs"
@@ -171,10 +163,6 @@ path = "examples/app/return_after_run.rs"
171163
name = "thread_pool_resources"
172164
path = "examples/app/thread_pool_resources.rs"
173165

174-
[[example]]
175-
name = "tracing"
176-
path = "examples/app/tracing.rs"
177-
178166
[[example]]
179167
name = "hot_asset_reloading"
180168
path = "examples/asset/hot_asset_reloading.rs"

crates/bevy_app/Cargo.toml

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ license = "MIT"
1313
keywords = ["bevy"]
1414

1515
[features]
16-
trace = [ "tracing" ]
16+
trace = []
1717

1818
[dependencies]
1919
# bevy
@@ -22,9 +22,7 @@ bevy_ecs = { path = "../bevy_ecs", version = "0.3.0" }
2222
bevy_utils = { path = "../bevy_utils", version = "0.3.0" }
2323

2424
# other
25-
log = { version = "0.4", features = ["release_max_level_info"] }
2625
serde = { version = "1.0", features = ["derive"] }
27-
tracing = { version = "0.1.21", optional = true }
2826

2927
[target.'cfg(target_arch = "wasm32")'.dependencies]
3028
wasm-bindgen = { version = "0.2" }

crates/bevy_app/src/app.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::app_builder::AppBuilder;
22
use bevy_ecs::{ParallelExecutor, Resources, Schedule, World};
33
#[cfg(feature = "trace")]
4-
use tracing::info_span;
4+
use bevy_utils::tracing::info_span;
55

66
#[allow(clippy::needless_doctest_main)]
77
/// Containers of app logic and data

crates/bevy_app/src/app_builder.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::{
55
stage, startup_stage, PluginGroup, PluginGroupBuilder,
66
};
77
use bevy_ecs::{FromResources, IntoSystem, Resources, System, World};
8+
use bevy_utils::tracing::debug;
89

910
/// Configure [App]s using the builder pattern
1011
pub struct AppBuilder {
@@ -267,7 +268,7 @@ impl AppBuilder {
267268
where
268269
T: Plugin,
269270
{
270-
log::debug!("added plugin: {}", plugin.name());
271+
debug!("added plugin: {}", plugin.name());
271272
plugin.build(self);
272273
self
273274
}

crates/bevy_app/src/plugin_group.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{AppBuilder, Plugin};
2-
use bevy_utils::HashMap;
2+
use bevy_utils::{tracing::debug, HashMap};
33
use std::any::TypeId;
44

55
pub trait PluginGroup {
@@ -94,7 +94,7 @@ impl PluginGroupBuilder {
9494
for ty in self.order.iter() {
9595
if let Some(entry) = self.plugins.get(ty) {
9696
if entry.enabled {
97-
log::debug!("added plugin: {}", entry.plugin.name());
97+
debug!("added plugin: {}", entry.plugin.name());
9898
entry.plugin.build(app);
9999
}
100100
}

crates/bevy_asset/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ crossbeam-channel = "0.4.4"
3333
anyhow = "1.0"
3434
thiserror = "1.0"
3535
downcast-rs = "1.2.0"
36-
log = { version = "0.4", features = ["release_max_level_info"] }
3736
notify = { version = "5.0.0-pre.2", optional = true }
3837
parking_lot = "0.11.0"
3938
rand = "0.7.3"

crates/bevy_core/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,5 @@ bevy_math = { path = "../bevy_math", version = "0.3.0" }
2323
bevy_utils = { path = "../bevy_utils", version = "0.3.0" }
2424
bevy_tasks = { path = "../bevy_tasks", version = "0.3.0" }
2525

26-
log = { version = "0.4", features = ["release_max_level_info"] }
27-
2826
[target.'cfg(target_arch = "wasm32")'.dependencies]
2927
instant = { version = "0.1", features = ["wasm-bindgen"] }

crates/bevy_core/src/task_pool_options.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use bevy_ecs::Resources;
22
use bevy_tasks::{AsyncComputeTaskPool, ComputeTaskPool, IoTaskPool, TaskPoolBuilder};
3+
use bevy_utils::tracing::trace;
34

45
/// Defines a simple way to determine how many threads to use given the number of remaining cores
56
/// and number of total cores
@@ -96,7 +97,7 @@ impl DefaultTaskPoolOptions {
9697
self.min_total_threads,
9798
self.max_total_threads,
9899
);
99-
log::trace!("Assigning {} cores to default task pools", total_threads);
100+
trace!("Assigning {} cores to default task pools", total_threads);
100101

101102
let mut remaining_threads = total_threads;
102103

@@ -106,7 +107,7 @@ impl DefaultTaskPoolOptions {
106107
.io
107108
.get_number_of_threads(remaining_threads, total_threads);
108109

109-
log::trace!("IO Threads: {}", io_threads);
110+
trace!("IO Threads: {}", io_threads);
110111
remaining_threads = remaining_threads.saturating_sub(io_threads);
111112

112113
resources.insert(IoTaskPool(
@@ -123,7 +124,7 @@ impl DefaultTaskPoolOptions {
123124
.async_compute
124125
.get_number_of_threads(remaining_threads, total_threads);
125126

126-
log::trace!("Async Compute Threads: {}", async_compute_threads);
127+
trace!("Async Compute Threads: {}", async_compute_threads);
127128
remaining_threads = remaining_threads.saturating_sub(async_compute_threads);
128129

129130
resources.insert(AsyncComputeTaskPool(
@@ -141,7 +142,7 @@ impl DefaultTaskPoolOptions {
141142
.compute
142143
.get_number_of_threads(remaining_threads, total_threads);
143144

144-
log::trace!("Compute Threads: {}", compute_threads);
145+
trace!("Compute Threads: {}", compute_threads);
145146
resources.insert(ComputeTaskPool(
146147
TaskPoolBuilder::default()
147148
.num_threads(compute_threads)

crates/bevy_diagnostic/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ repository = "https://github.com/bevyengine/bevy"
1212
license = "MIT"
1313
keywords = ["bevy"]
1414

15-
[features]
16-
profiler = ["bevy_ecs/profiler"]
1715

1816
[dependencies]
1917
# bevy

crates/bevy_diagnostic/src/lib.rs

-13
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
mod diagnostic;
22
mod frame_time_diagnostics_plugin;
33
mod print_diagnostics_plugin;
4-
#[cfg(feature = "profiler")]
5-
mod system_profiler;
64
pub use diagnostic::*;
75
pub use frame_time_diagnostics_plugin::FrameTimeDiagnosticsPlugin;
86
pub use print_diagnostics_plugin::PrintDiagnosticsPlugin;
@@ -16,16 +14,5 @@ pub struct DiagnosticsPlugin;
1614
impl Plugin for DiagnosticsPlugin {
1715
fn build(&self, app: &mut AppBuilder) {
1816
app.init_resource::<Diagnostics>();
19-
#[cfg(feature = "profiler")]
20-
{
21-
use bevy_ecs::IntoSystem;
22-
app.add_resource::<Box<dyn bevy_ecs::Profiler>>(Box::new(
23-
system_profiler::SystemProfiler::default(),
24-
))
25-
.add_system_to_stage(
26-
bevy_app::stage::LAST,
27-
system_profiler::profiler_diagnostic_system.system(),
28-
);
29-
}
3017
}
3118
}

crates/bevy_diagnostic/src/system_profiler.rs

-71
This file was deleted.

crates/bevy_dynamic_plugin/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@ keywords = ["bevy"]
1919
bevy_app = { path = "../bevy_app", version = "0.3.0" }
2020

2121
# other
22-
log = { version = "0.4", features = ["release_max_level_info"] }
2322
libloading = { version = "0.6" }

crates/bevy_dynamic_plugin/src/loader.rs

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ pub trait DynamicPluginExt {
2020
impl DynamicPluginExt for AppBuilder {
2121
fn load_plugin(&mut self, path: &str) -> &mut Self {
2222
let (_lib, plugin) = dynamically_load_plugin(path);
23-
log::debug!("loaded plugin: {}", plugin.name());
2423
plugin.build(self);
2524
self
2625
}

crates/bevy_ecs/Cargo.toml

+1-4
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ keywords = ["ecs", "game", "bevy"]
1414
categories = ["game-engines", "data-structures"]
1515

1616
[features]
17-
profiler = []
18-
trace = [ "tracing" ]
17+
trace = []
1918

2019
[dependencies]
2120
bevy_hecs = { path = "hecs", features = ["macros", "serialize"], version = "0.3.0" }
@@ -26,5 +25,3 @@ thiserror = "1.0"
2625
fixedbitset = "0.3.1"
2726
downcast-rs = "1.2.0"
2827
parking_lot = "0.11.0"
29-
log = { version = "0.4", features = ["release_max_level_info"] }
30-
tracing = { version = "0.1.21", optional = true }

crates/bevy_ecs/src/schedule/parallel_executor.rs

+6-19
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ use crate::{
55
};
66
use bevy_hecs::{ArchetypesGeneration, TypeAccess, World};
77
use bevy_tasks::{ComputeTaskPool, CountdownEvent, TaskPool};
8+
#[cfg(feature = "trace")]
9+
use bevy_utils::tracing::info_span;
10+
use bevy_utils::tracing::trace;
811
use fixedbitset::FixedBitSet;
912
use std::ops::Range;
10-
#[cfg(feature = "trace")]
11-
use tracing::info_span;
1213

1314
/// Executes each schedule stage in parallel by analyzing system dependencies.
1415
/// System execution order is undefined except under the following conditions:
@@ -68,7 +69,6 @@ impl ParallelExecutor {
6869
let stage_span = info_span!("stage", name = stage_name.as_ref());
6970
#[cfg(feature = "trace")]
7071
let _stage_guard = stage_span.enter();
71-
log::trace!("run stage {:?}", stage_name);
7272
if let Some(stage_systems) = schedule.stages.get_mut(stage_name) {
7373
executor_stage.run(world, resources, stage_systems, schedule_changed);
7474
}
@@ -334,12 +334,12 @@ impl ExecutorStage {
334334
compute_pool: &TaskPool,
335335
) {
336336
// Generate tasks for systems in the given range and block until they are complete
337-
log::trace!("running systems {:?}", prepared_system_range);
337+
trace!("running systems {:?}", prepared_system_range);
338338
compute_pool.scope(|scope| {
339339
let start_system_index = prepared_system_range.start;
340340
let mut system_index = start_system_index;
341341
for system in &mut systems[prepared_system_range] {
342-
log::trace!(
342+
trace!(
343343
"prepare {} {} with {} dependents and {} dependencies",
344344
system_index,
345345
system.name(),
@@ -381,12 +381,6 @@ impl ExecutorStage {
381381
for (trigger_event, dependent_system_index) in
382382
trigger_events.iter().zip(dependent_systems)
383383
{
384-
log::trace!(
385-
" * system ({}) triggers events: ({}): {}",
386-
system_index,
387-
dependent_system_index,
388-
trigger_event.get()
389-
);
390384
debug_assert!(
391385
*dependent_system_index < start_system_index || trigger_event.get() > 0
392386
);
@@ -408,12 +402,7 @@ impl ExecutorStage {
408402
#[cfg(feature = "trace")]
409403
let _system_guard = system_span.enter();
410404

411-
log::trace!("run {}", system.name());
412-
#[cfg(feature = "profiler")]
413-
crate::profiler_start(resources, system.name().clone());
414405
system.run(world_ref, resources_ref);
415-
#[cfg(feature = "profiler")]
416-
crate::profiler_stop(resources, system.name().clone());
417406
}
418407

419408
// Notify dependents that this task is done
@@ -506,11 +495,10 @@ impl ExecutorStage {
506495
let system = systems[thread_local_system_index].as_mut();
507496

508497
#[cfg(feature = "trace")]
509-
let system_span = info_span!("system", name = system.name().as_ref());
498+
let system_span = info_span!("thread_local_system", name = system.name().as_ref());
510499
#[cfg(feature = "trace")]
511500
let _system_guard = system_span.enter();
512501

513-
log::trace!("running thread local system {}", system.name());
514502
system.run(world, resources);
515503
system.run_thread_local(world, resources);
516504
}
@@ -527,7 +515,6 @@ impl ExecutorStage {
527515
next_thread_local_index,
528516
);
529517

530-
log::trace!("running systems {:?}", run_ready_system_index_range);
531518
self.run_systems(
532519
world,
533520
resources,

0 commit comments

Comments
 (0)