compositing/
tracing.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5/// Log an event from constellation at trace level.
6/// - To disable tracing: RUST_LOG='compositor<constellation@=off'
7/// - To enable tracing: RUST_LOG='compositor<constellation@'
8macro_rules! trace_msg_from_constellation {
9    // This macro only exists to put the docs in the same file as the target prefix,
10    // so the macro definition is always the same.
11    ($event:expr, $($rest:tt)+) => {
12        ::log::trace!(target: $crate::tracing::LogTarget::log_target(&$event), $($rest)+)
13    };
14}
15
16/// Get the log target for an event, as a static string.
17pub(crate) trait LogTarget {
18    fn log_target(&self) -> &'static str;
19}
20
21mod from_constellation {
22    use super::LogTarget;
23
24    macro_rules! target {
25        ($($name:literal)+) => {
26            concat!("compositor<constellation@", $($name),+)
27        };
28    }
29
30    impl LogTarget for compositing_traits::CompositorMsg {
31        fn log_target(&self) -> &'static str {
32            match self {
33                Self::ChangeRunningAnimationsState(..) => target!("ChangeRunningAnimationsState"),
34                Self::CreateOrUpdateWebView(..) => target!("CreateOrUpdateWebView"),
35                Self::RemoveWebView(..) => target!("RemoveWebView"),
36                Self::TouchEventProcessed(..) => target!("TouchEventProcessed"),
37                Self::IsReadyToSaveImageReply(..) => target!("IsReadyToSaveImageReply"),
38                Self::SetThrottled(..) => target!("SetThrottled"),
39                Self::NewWebRenderFrameReady(..) => target!("NewWebRenderFrameReady"),
40                Self::PipelineExited(..) => target!("PipelineExited"),
41                Self::LoadComplete(..) => target!("LoadComplete"),
42                Self::SendInitialTransaction(..) => target!("SendInitialTransaction"),
43                Self::SendScrollNode(..) => target!("SendScrollNode"),
44                Self::SendDisplayList { .. } => target!("SendDisplayList"),
45                Self::GenerateFrame { .. } => target!("GenerateFrame"),
46                Self::GenerateImageKey(..) => target!("GenerateImageKey"),
47                Self::UpdateImages(..) => target!("UpdateImages"),
48                Self::GenerateFontKeys(..) => target!("GenerateFontKeys"),
49                Self::AddFont(..) => target!("AddFont"),
50                Self::AddSystemFont(..) => target!("AddSystemFont"),
51                Self::AddFontInstance(..) => target!("AddFontInstance"),
52                Self::RemoveFonts(..) => target!("RemoveFonts"),
53                Self::CollectMemoryReport(..) => target!("CollectMemoryReport"),
54                Self::Viewport(..) => target!("Viewport"),
55                Self::GenerateImageKeysForPipeline(..) => target!("GenerateImageKeysForPipeline"),
56                Self::DelayNewFrameForCanvas(..) => target!("DelayFramesForCanvas"),
57            }
58        }
59    }
60}