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

feat(logging)!: Move logging setup to setup_logging, disable bevy LogPlugin, add logging to file system #446

Merged
merged 19 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
82 changes: 82 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions demos/assets_minimal/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ struct GameMeta {
}

fn main() {
// Setup logging
setup_logs!();

// First create bones game.
let mut game = Game::new();

Expand Down
3 changes: 3 additions & 0 deletions demos/features/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ struct TileMeta {
struct PersistedTextData(String);

fn main() {
// Setup logging
setup_logs!();

// Register persistent data's schema so that it can be loaded by the storage loader.
PersistedTextData::register_schema();

Expand Down
3 changes: 3 additions & 0 deletions demos/hello_world/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ use bones_bevy_renderer::BonesBevyRenderer;
use bones_framework::prelude::*;

fn main() {
// Setup logging
setup_logs!();

// First create bones game.
let mut game = Game::new();

Expand Down
3 changes: 3 additions & 0 deletions demos/scripting/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ struct GameMeta {
}

fn main() {
// Setup logging
setup_logs!();

let mut game = Game::new();
game.install_plugin(DefaultGamePlugin);
game.shared_resource_mut::<AssetServer>()
Expand Down
3 changes: 2 additions & 1 deletion framework_crates/bones_bevy_renderer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use render::*;
mod ui;
use ui::*;
mod rumble;
use bevy::prelude::*;
use bevy::{log::LogPlugin, prelude::*};
use bones::GamepadsRumble;
use bones_framework::prelude as bones;
use rumble::*;
Expand Down Expand Up @@ -145,6 +145,7 @@ impl BonesBevyRenderer {
}),
..default()
})
.disable::<LogPlugin>()
.build();
if self.pixel_art {
plugins = plugins.set(ImagePlugin::default_nearest());
Expand Down
23 changes: 21 additions & 2 deletions framework_crates/bones_framework/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ categories.workspace = true
keywords.workspace = true

[features]
default = ["image_png", "ui", "localization", "audio", "audio_ogg", "scripting"]
default = ["image_png", "ui", "localization", "logging", "audio", "audio_ogg", "scripting"]
#! Cargo feature supported in `bones_framework`.

## Enable the `ui` module, powered by [`egui`].
ui = ["dep:egui", "dep:ttf-parser"]
## Enable the localization module, powered by [`fluent`](https://github.com/projectfluent/fluent-rs).
localization = ["dep:fluent", "dep:fluent-langneg", "dep:intl-memoizer", "dep:unic-langid", "dep:sys-locale"]

logging = ["dep:tracing-subscriber", "dep:tracing-wasm", "dep:tracing-appender"]

## Enable the audio system.
audio = ["dep:kira"]

Expand Down Expand Up @@ -71,6 +73,12 @@ image_bmp = ["image/bmp"]
## Simulate dramatic network latency by inserting random sleeps into the networking code. This is extremely cheap and hacky but may be useful.
debug-network-slowdown = []

# Enables tracy tracing subscriber to capture tracing spans for profiling with Tracy.
#
# Note that bones is primarily instrumented with puffin scopes, tracy only captures tracing spans.
# This flag only enables span capture in logging plugin, `bevy/trace_tracy` may be used to enable tracy.
tracing-tracy = ["logging", "dep:tracing-tracy"]

document-features = ["dep:document-features"]

[dependencies]
Expand All @@ -92,7 +100,12 @@ instant = { version = "0.1", features = ["wasm-bindgen"] }
noise = "0.9"
once_cell = "1.17"
thiserror = "1.0"
tracing = "0.1"

# Tracing
tracing = "0.1"
tracing-subscriber = { version = "0.3", optional = true, features = ["env-filter"] }
tracing-appender = { version = "0.2", optional = true, features = ["parking_lot"] }
tracing-tracy = { version = "0.11.0", optional = true, default-features = false }

# Render
csscolorparser = "0.6"
Expand Down Expand Up @@ -139,3 +152,9 @@ smallvec = "1.10"
iroh-quinn = { version = "0.10" }
iroh-net = { version = "0.22" }
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }


directories = "5.0"

[target.'cfg(target_arch = "wasm32")'.dependencies]
tracing-wasm = { version = "0.2.1", optional = true }
6 changes: 6 additions & 0 deletions framework_crates/bones_framework/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ pub mod prelude {

#[cfg(feature = "localization")]
pub use crate::localization::*;

#[cfg(feature = "logging")]
pub use crate::logging::prelude::*;
}

pub mod animation;
Expand All @@ -67,6 +70,9 @@ pub use bones_scripting as scripting;
#[cfg(feature = "localization")]
pub mod localization;

#[cfg(feature = "logging")]
pub mod logging;

/// External crate documentation.
///
/// This module only exists during docs builds and serves to make it eaiser to link to relevant
Expand Down
Loading
Loading