bevy/examples/app
Jean Mertz 3b24f520b9
feat(log): support customizing default log formatting (#17722)
The LogPlugin now allows overriding the default
`tracing_subscriber::fmt::Layer` through a new `fmt_layer` option. This
enables customization of the default log output format without having to
replace the entire logging system.

For example, to disable timestamps in the log output:

```rust
fn fmt_layer(_app: &mut App) -> Option<bevy::log::BoxedFmtLayer> {
    Some(Box::new(
        bevy::log::tracing_subscriber::fmt::Layer::default()
            .without_time()
            .with_writer(std::io::stderr),
    ))
}

fn main() {
    App::new()
        .add_plugins(DefaultPlugins.set(bevy::log::LogPlugin {
            fmt_layer,
            ..default()
        }))
        .run();
}
```

This is different from the existing `custom_layer` option, because that
option _adds_ additional layers to the subscriber, but can't modify the
default formatter layer (at least, not to my knowledge).

I almost always disable timestamps in my Bevy logs, and usually also
tweak other default log formatting (such as `with_span_events`), which
made it so that I always had to disable the default logger. This allows
me to use everything the Bevy logger supports (including tracy support),
while still formatting the default logs the way I like them.

---------

Signed-off-by: Jean Mertz <git@jeanmertz.com>
2025-05-05 23:01:06 +00:00
..
custom_loop.rs Renamed EventWriter::send methods to write. (#17977) 2025-02-23 21:18:52 +00:00
drag_and_drop.rs
empty_defaults.rs
empty.rs
headless_renderer.rs Renamed EventWriter::send methods to write. (#17977) 2025-02-23 21:18:52 +00:00
headless.rs Fix compile errors on headless example (#18497) 2025-03-23 21:24:20 +00:00
log_layers_ecs.rs feat(log): support customizing default log formatting (#17722) 2025-05-05 23:01:06 +00:00
log_layers.rs feat(log): support customizing default log formatting (#17722) 2025-05-05 23:01:06 +00:00
logs.rs Merge Style properties into Node. Use ComputedNode for computed properties. (#15975) 2024-10-18 22:25:33 +00:00
no_renderer.rs Add configuration for async pipeline creation on RenderPlugin (#11847) 2024-02-16 13:35:47 +00:00
plugin_group.rs Remove second generic from .add_before, .add_after (#14285) 2024-07-15 15:58:14 +00:00
plugin.rs Remove everything except Instant from bevy_utils::time (#17158) 2025-01-05 20:36:08 +00:00
return_after_run.rs
thread_pool_resources.rs
without_winit.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00