From 250cc63ddf50435a5e39bd0185c21080f878b9e6 Mon Sep 17 00:00:00 2001 From: Zachary Harrold Date: Tue, 3 Sep 2024 10:48:19 +1000 Subject: [PATCH] Updated `LogPlugin` Documentation with Performance Warning (#14984) # Objective - Fixes #14966 ## Solution - Added a _Performance_ section to the documentation for `LogPlugin::filter` explaining that long filter strings can degrade performance and to instead rely on `LogPlugin::level` when possible. ## Testing - CI passed locally. --- crates/bevy_log/src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/bevy_log/src/lib.rs b/crates/bevy_log/src/lib.rs index 53f1dbd6d1..b3c1991769 100644 --- a/crates/bevy_log/src/lib.rs +++ b/crates/bevy_log/src/lib.rs @@ -133,6 +133,20 @@ pub(crate) struct FlushGuard(SyncCell); /// This plugin should not be added multiple times in the same process. This plugin /// sets up global logging configuration for **all** Apps in a given process, and /// rerunning the same initialization multiple times will lead to a panic. +/// +/// # Performance +/// +/// Filters applied through this plugin are computed at _runtime_, which will +/// have a non-zero impact on performance. +/// To achieve maximum performance, consider using +/// [_compile time_ filters](https://docs.rs/log/#compile-time-filters) +/// provided by the [`log`](https://crates.io/crates/log) crate. +/// +/// ```toml +/// # cargo.toml +/// [dependencies] +/// log = { version = "0.4", features = ["max_level_debug", "release_max_level_warn"] } +/// ``` pub struct LogPlugin { /// Filters logs using the [`EnvFilter`] format pub filter: String,