Open-Source Wikis

/

Bevy

/

Packages

/

bevy_log

bevyengine/bevy

bevy_log

tracing integration. Installs a tracing-subscriber, wires the log crate facade through to tracing, and registers a panic hook that emits a structured panic event.

Purpose

Most Bevy crates use tracing::info! / tracing::error! / tracing::span! directly. bevy_log::LogPlugin is the plugin that puts a subscriber on the wire so those messages actually go somewhere.

The crate also makes it easy to plug in alternative backends (Tracy, Chrome JSON, OpenTelemetry) via cargo features.

Directory layout

crates/bevy_log/src/
├── lib.rs                # LogPlugin + filter/level config
├── android_tracing.rs    # Android logcat backend
└── once.rs               # Helpers for "log this once"

Key abstractions

Type File Description
LogPlugin crates/bevy_log/src/lib.rs Adds a tracing subscriber.
Level crates/bevy_log/src/lib.rs Re-export of tracing::Level.
BoxedLayer crates/bevy_log/src/lib.rs Custom tracing-subscriber::Layer injection.
info_once!, warn_once!, error_once! crates/bevy_log/src/once.rs Log-once macros.

How it works

LogPlugin::build constructs a tracing-subscriber::Registry with a fmt::Layer (configurable filter and level) and any additional layers users provide. It also calls tracing_log::LogTracer::init so calls to the log crate's macros get re-emitted as tracing events.

On Android, android_tracing.rs adds a layer that forwards to __android_log_print. On Wasm, the default fmt::Layer is configured to write to the console via tracing-wasm.

Backend features in Cargo.toml:

  • trace_tracy — Tracy
  • trace_chrome — Chrome JSON
  • tracing-tracy, tracing-chrome, tracing-wasm — the underlying integrations.

Integration points

  • Depends on: tracing, tracing-subscriber, tracing-log, optional Tracy/Chrome layers.
  • Depended on by: Every crate that emits tracing events (i.e. nearly all of them).

Entry points for modification

  • Add a new backend: new layer in LogPlugin::build, gated by a cargo feature.
  • Default filter: LogPlugin { filter, level, ... }.
  • Custom layers: users supply Box<dyn Layer<Registry>> via LogPlugin { custom_layer: Some(...), ... }.

See also

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

bevy_log – Bevy wiki | Factory