Skip to content
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

Log Plugin #836

Merged
merged 4 commits into from
Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand All @@ -74,17 +74,9 @@ 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"

[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"
Expand Down Expand Up @@ -146,6 +138,10 @@ path = "examples/app/empty_defaults.rs"
name = "empty"
path = "examples/app/empty.rs"

[[example]]
name = "logs"
path = "examples/app/logs.rs"

[[example]]
name = "headless"
path = "examples/app/headless.rs"
Expand All @@ -166,10 +162,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"
Expand Down Expand Up @@ -332,6 +324,6 @@ apk_label = "Bevy Example"
assets = "assets"
res = "assets/android-res"
icon = "@mipmap/ic_launcher"
build_targets = ["aarch64-linux-android", "armv7-linux-androideabi"]
build_targets = ["aarch64-linux-android", "armv7-linux-androideabi"]
min_sdk_version = 16
target_sdk_version = 29
4 changes: 1 addition & 3 deletions crates/bevy_app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ license = "MIT"
keywords = ["bevy"]

[features]
trace = [ "tracing" ]
trace = []

[dependencies]
# bevy
Expand All @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_app/src/app_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -267,7 +268,7 @@ impl AppBuilder {
where
T: Plugin,
{
log::debug!("added plugin: {}", plugin.name());
debug!("added plugin: {}", plugin.name());
plugin.build(self);
self
}
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_app/src/plugin_group.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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);
}
}
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_asset/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions crates/bevy_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
9 changes: 5 additions & 4 deletions crates/bevy_core/src/task_pool_options.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;

Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions crates/bevy_diagnostic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ repository = "https://github.com/bevyengine/bevy"
license = "MIT"
keywords = ["bevy"]

[features]
profiler = ["bevy_ecs/profiler"]

[dependencies]
# bevy
Expand Down
13 changes: 0 additions & 13 deletions crates/bevy_diagnostic/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -16,16 +14,5 @@ pub struct DiagnosticsPlugin;
impl Plugin for DiagnosticsPlugin {
fn build(&self, app: &mut AppBuilder) {
app.init_resource::<Diagnostics>();
#[cfg(feature = "profiler")]
{
use bevy_ecs::IntoSystem;
app.add_resource::<Box<dyn bevy_ecs::Profiler>>(Box::new(
system_profiler::SystemProfiler::default(),
))
.add_system_to_stage(
bevy_app::stage::LAST,
system_profiler::profiler_diagnostic_system.system(),
);
}
}
}
71 changes: 0 additions & 71 deletions crates/bevy_diagnostic/src/system_profiler.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/bevy_dynamic_plugin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
1 change: 0 additions & 1 deletion crates/bevy_dynamic_plugin/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 1 addition & 4 deletions crates/bevy_ecs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -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 }
25 changes: 6 additions & 19 deletions crates/bevy_ecs/src/schedule/parallel_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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
);
Expand All @@ -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
Expand Down Expand Up @@ -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);
}
Expand All @@ -527,7 +515,6 @@ impl ExecutorStage {
next_thread_local_index,
);

log::trace!("running systems {:?}", run_ready_system_index_range);
self.run_systems(
world,
resources,
Expand Down
Loading