From d623731e2c0f4c5ce4213a30685e73e190db60b4 Mon Sep 17 00:00:00 2001 From: James Liu Date: Mon, 10 Apr 2023 20:37:58 -0700 Subject: [PATCH] Move event traces to detailed_trace! (#7732) # Objective Noticed while writing #7728 that we are using `trace!` logs in our event functions. This has shown to have significant overhead, even trace level logs are disabled globally, as seen in #7639. ## Solution Use the `detailed_trace!` macro introduced in #7639. Also removed the `event_trace` function that was only used in one location. --- ## Changelog Changed: Event trace logs are now feature gated behind the `detailed-trace` feature. --- crates/bevy_ecs/src/event.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/crates/bevy_ecs/src/event.rs b/crates/bevy_ecs/src/event.rs index 02e71e0f6b34c..f0e5f26f74cf2 100644 --- a/crates/bevy_ecs/src/event.rs +++ b/crates/bevy_ecs/src/event.rs @@ -2,7 +2,7 @@ use crate as bevy_ecs; use crate::system::{Local, Res, ResMut, Resource, SystemParam}; -use bevy_utils::tracing::trace; +use bevy_utils::detailed_trace; use std::ops::{Deref, DerefMut}; use std::{fmt, hash::Hash, iter::Chain, marker::PhantomData, slice::Iter}; /// A type that can be stored in an [`Events`] resource @@ -419,10 +419,6 @@ pub struct ManualEventIteratorWithId<'a, E: Event> { unread: usize, } -fn event_trace(id: EventId) { - trace!("EventReader::iter() -> {}", id); -} - impl<'a, E: Event> ManualEventIteratorWithId<'a, E> { pub fn new(reader: &'a mut ManualEventReader, events: &'a Events) -> Self { let a_index = (reader.last_event_count).saturating_sub(events.events_a.start_event_count); @@ -459,7 +455,7 @@ impl<'a, E: Event> Iterator for ManualEventIteratorWithId<'a, E> { .map(|instance| (&instance.event, instance.event_id)) { Some(item) => { - event_trace(item.1); + detailed_trace!("EventReader::iter() -> {}", item.1); self.reader.last_event_count += 1; self.unread -= 1; Some(item) @@ -513,7 +509,7 @@ impl Events { id: self.event_count, _marker: PhantomData, }; - trace!("Events::send() -> id: {}", event_id); + detailed_trace!("Events::send() -> id: {}", event_id); let event_instance = EventInstance { event_id, event }; @@ -654,7 +650,7 @@ impl std::iter::Extend for Events { self.events_b.extend(events); if old_count != event_count { - trace!( + detailed_trace!( "Events::extend() -> ids: ({}..{})", self.event_count, event_count