mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
Document use of NO_COLOR
in LogPlugin
(#13984)
# Objective Fixes #13982 ## Solution ~~Adds a new field to `bevy_log::LogPlugin`: `ansi: bool`~~ Documents the use of `std::env::set_var("NO_COLOR", "1");` to disable colour output in terminals. ## Testing Yes, all tests passed when I ran `cargo run -p ci -- test` and `cargo run -p ci -- lints` I have only tested the code on my Mac, though I doubt this change would have any affect on other platforms. ---
This commit is contained in:
parent
d48ebdf641
commit
82fd3df719
1 changed files with 18 additions and 0 deletions
|
@ -101,6 +101,21 @@ pub(crate) struct FlushGuard(SyncCell<tracing_chrome::FlushGuard>);
|
|||
/// If you define the `RUST_LOG` environment variable, the [`LogPlugin`] settings
|
||||
/// will be ignored.
|
||||
///
|
||||
/// Also, to disable colour terminal output (ANSI escape codes), you can
|
||||
/// set the environment variable `NO_COLOR` to any value. This common
|
||||
/// convention is documented at [no-color.org](https://no-color.org/).
|
||||
/// For example:
|
||||
/// ```no_run
|
||||
/// # use bevy_app::{App, NoopPluginGroup as DefaultPlugins, PluginGroup};
|
||||
/// # use bevy_log::LogPlugin;
|
||||
/// fn main() {
|
||||
/// std::env::set_var("NO_COLOR", "1");
|
||||
/// App::new()
|
||||
/// .add_plugins(DefaultPlugins)
|
||||
/// .run();
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// If you want to setup your own tracing collector, you should disable this
|
||||
/// plugin from `DefaultPlugins`:
|
||||
/// ```no_run
|
||||
|
@ -218,6 +233,9 @@ impl Plugin for LogPlugin {
|
|||
#[cfg(feature = "tracing-tracy")]
|
||||
let tracy_layer = tracing_tracy::TracyLayer::default();
|
||||
|
||||
// note: the implementation of `Default` reads from the env var NO_COLOR
|
||||
// to decide whether to use ANSI color codes, which is common convention
|
||||
// https://no-color.org/
|
||||
let fmt_layer = tracing_subscriber::fmt::Layer::default().with_writer(std::io::stderr);
|
||||
|
||||
// bevy_render::renderer logs a `tracy.frame_mark` event every frame
|
||||
|
|
Loading…
Reference in a new issue