| #![allow(dead_code)] |
| pub mod event; |
| pub mod field; |
| mod metadata; |
| pub mod span; |
| pub mod subscriber; |
| |
| #[derive(Debug, Eq, PartialEq)] |
| pub(in crate::support) enum Parent { |
| ContextualRoot, |
| Contextual(String), |
| ExplicitRoot, |
| Explicit(String), |
| } |
| |
| impl Parent { |
| pub(in crate::support) fn check_parent_name( |
| &self, |
| parent_name: Option<&str>, |
| provided_parent: Option<tracing_core::span::Id>, |
| ctx: impl std::fmt::Display, |
| subscriber_name: &str, |
| ) { |
| match self { |
| Parent::ExplicitRoot => { |
| assert!( |
| provided_parent.is_none(), |
| "[{}] expected {} to be an explicit root, but its parent was actually {:?} (name: {:?})", |
| subscriber_name, |
| ctx, |
| provided_parent, |
| parent_name, |
| ); |
| } |
| Parent::Explicit(expected_parent) => { |
| assert_eq!( |
| Some(expected_parent.as_ref()), |
| parent_name, |
| "[{}] expected {} to have explicit parent {}, but its parent was actually {:?} (name: {:?})", |
| subscriber_name, |
| ctx, |
| expected_parent, |
| provided_parent, |
| parent_name, |
| ); |
| } |
| Parent::ContextualRoot => { |
| assert!( |
| provided_parent.is_none(), |
| "[{}] expected {} to have a contextual parent, but its parent was actually {:?} (name: {:?})", |
| subscriber_name, |
| ctx, |
| provided_parent, |
| parent_name, |
| ); |
| assert!( |
| parent_name.is_none(), |
| "[{}] expected {} to be contextual a root, but we were inside span {:?}", |
| subscriber_name, |
| ctx, |
| parent_name, |
| ); |
| } |
| Parent::Contextual(expected_parent) => { |
| assert!(provided_parent.is_none(), |
| "[{}] expected {} to have a contextual parent\nbut its parent was actually {:?} (name: {:?})", |
| subscriber_name, |
| ctx, |
| provided_parent, |
| parent_name, |
| ); |
| assert_eq!( |
| Some(expected_parent.as_ref()), |
| parent_name, |
| "[{}] expected {} to have contextual parent {:?}, but got {:?}", |
| subscriber_name, |
| ctx, |
| expected_parent, |
| parent_name, |
| ); |
| } |
| } |
| } |
| } |