summaryrefslogtreecommitdiffstats
path: root/vendor/gix-trace/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /vendor/gix-trace/src
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix-trace/src')
-rw-r--r--vendor/gix-trace/src/disabled.rs105
-rw-r--r--vendor/gix-trace/src/enabled.rs438
-rw-r--r--vendor/gix-trace/src/lib.rs632
3 files changed, 1175 insertions, 0 deletions
diff --git a/vendor/gix-trace/src/disabled.rs b/vendor/gix-trace/src/disabled.rs
new file mode 100644
index 000000000..a4a12787c
--- /dev/null
+++ b/vendor/gix-trace/src/disabled.rs
@@ -0,0 +1,105 @@
+/// A workaround for a clippy warning
+#[doc(hidden)]
+#[derive(Clone)]
+pub struct Span;
+
+impl Span {
+ /// A no-op
+ pub fn record<V>(&self, _field: &str, _value: V) -> &Self {
+ self
+ }
+}
+
+/// A macro to create a span.
+#[macro_export]
+macro_rules! span {
+ (target: $target:expr, $lvl:expr, $name:expr, $($fields:tt)*) => {
+ $crate::Span
+ };
+ (target: $target:expr, $lvl:expr, $name:expr) => {
+ $crate::span!(target: $target, $lvl, $name,)
+ };
+ ($lvl:expr, $name:expr, $($fields:tt)*) => {
+ $crate::span!(
+ target: module_path!(),
+ $lvl,
+ $name,
+ $($fields)*
+ )
+ };
+ ($lvl:expr, $name:expr) => {
+ $crate::span!(
+ target: module_path!(),
+ $lvl,
+ $name,
+ )
+ };
+}
+
+/// Create an event with the given level.
+#[macro_export]
+macro_rules! event {
+ (target: $target:expr, $lvl:expr, { $($fields:tt)* } )=> (
+ {}
+ );
+ (target: $target:expr, $lvl:expr, { $($fields:tt)* }, $($arg:tt)+ ) => (
+ $crate::event!(
+ target: $target,
+ $lvl,
+ { message = format_args!($($arg)+), $($fields)* }
+ )
+ );
+ (target: $target:expr, $lvl:expr, $($k:ident).+ = $($fields:tt)* ) => (
+ $crate::event!(target: $target, $lvl, { $($k).+ = $($fields)* })
+ );
+ (target: $target:expr, $lvl:expr, $($arg:tt)+ ) => (
+ $crate::event!(target: $target, $lvl, { $($arg)+ })
+ );
+ ( $lvl:expr, { $($fields:tt)* }, $($arg:tt)+ ) => (
+ $crate::event!(
+ target: module_path!(),
+ $lvl,
+ { message = format_args!($($arg)+), $($fields)* }
+ )
+ );
+ ($lvl:expr, $($k:ident).+ = $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $lvl,
+ { $($k).+ = $($field)*}
+ )
+ );
+ ($lvl:expr, $($k:ident).+, $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $lvl,
+ { $($k).+, $($field)*}
+ )
+ );
+ ($lvl:expr, ?$($k:ident).+, $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $lvl,
+ { ?$($k).+, $($field)*}
+ )
+ );
+ ($lvl:expr, %$($k:ident).+, $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $lvl,
+ { %$($k).+, $($field)*}
+ )
+ );
+ ($lvl:expr, ?$($k:ident).+) => (
+ $crate::event!($lvl, ?$($k).+,)
+ );
+ ($lvl:expr, %$($k:ident).+) => (
+ $crate::event!($lvl, %$($k).+,)
+ );
+ ($lvl:expr, $($k:ident).+) => (
+ $crate::event!($lvl, $($k).+,)
+ );
+ ( $lvl:expr, $($arg:tt)+ ) => (
+ $crate::event!(target: module_path!(), $lvl, { $($arg)+ })
+ );
+}
diff --git a/vendor/gix-trace/src/enabled.rs b/vendor/gix-trace/src/enabled.rs
new file mode 100644
index 000000000..554684016
--- /dev/null
+++ b/vendor/gix-trace/src/enabled.rs
@@ -0,0 +1,438 @@
+use tracing_core::{dispatcher::get_default as with_dispatcher, span, span::Id, Dispatch};
+// these are used later in macros.
+pub use tracing_core::{field, metadata, Event, Metadata};
+
+/// An entered span which will exit on drop.
+#[derive(Clone)]
+pub struct Span {
+ id: Option<(Id, Dispatch, &'static Metadata<'static>)>,
+}
+
+impl Span {
+ /// Create a new span.
+ ///
+ /// This constructor is typically invoked by the [`crate::span!`] macro.
+ pub fn new(
+ level: crate::Level,
+ meta: &'static Metadata<'static>,
+ values: &tracing_core::field::ValueSet<'_>,
+ ) -> Self {
+ if level > crate::MAX_LEVEL {
+ Self { id: None }
+ } else {
+ with_dispatcher(|dispatch| {
+ let id = dispatch.new_span(&tracing_core::span::Attributes::new(meta, values));
+ dispatch.enter(&id);
+ Self {
+ id: Some((id, dispatch.clone(), meta)),
+ }
+ })
+ }
+ }
+
+ /// Record a single `field` to take `value`.
+ ///
+ /// ### Panics
+ ///
+ /// If the field name wasn't mentioned when the span was created.
+ pub fn record<V>(&self, field: &str, value: V) -> &Self
+ where
+ V: field::Value,
+ {
+ if let Some((_, _, meta)) = &self.id {
+ let fields = meta.fields();
+ let field = fields
+ .field(field)
+ .unwrap_or_else(|| panic!("Field name '{field}' must be registered at creation time."));
+ self.record_all(&fields.value_set(&[(&field, Some(&value as &dyn field::Value))]));
+ }
+ self
+ }
+
+ fn record_all(&self, values: &field::ValueSet<'_>) -> &Self {
+ if let Some((id, dispatch, _)) = &self.id {
+ let record = span::Record::new(values);
+ dispatch.record(id, &record);
+ }
+ self
+ }
+}
+
+impl Drop for Span {
+ fn drop(&mut self) {
+ if let Some((id, dispatch, _meta)) = self.id.take() {
+ dispatch.exit(&id);
+ dispatch.try_close(id);
+ }
+ }
+}
+
+#[doc(hidden)]
+pub struct MetaOnlyCallsite(pub &'static Metadata<'static>);
+
+impl tracing_core::callsite::Callsite for MetaOnlyCallsite {
+ fn set_interest(&self, _: tracing_core::subscriber::Interest) {}
+
+ fn metadata(&self) -> &Metadata<'_> {
+ self.0
+ }
+}
+
+#[doc(hidden)]
+impl crate::Level {
+ pub const fn into_tracing_level(self) -> tracing_core::Level {
+ match self {
+ crate::Level::Coarse => tracing_core::Level::INFO,
+ crate::Level::Detail => tracing_core::Level::DEBUG,
+ }
+ }
+}
+
+/// A macro to create a span.
+#[macro_export]
+macro_rules! span {
+ (target: $target:expr, $lvl:expr, $name:expr, $($fields:tt)*) => {
+ {
+ static META: $crate::Metadata<'static> = {
+ $crate::metadata! {
+ name: $name,
+ target: $target,
+ level: $lvl.into_tracing_level(),
+ fields: $crate::fieldset!( $($fields)* ),
+ callsite: &$crate::MetaOnlyCallsite(&META),
+ kind: $crate::metadata::Kind::SPAN,
+ }
+ };
+
+ $crate::Span::new(
+ $lvl,
+ &META,
+ &$crate::valueset!(META.fields(), $($fields)*),
+ )
+ }
+ };
+ (target: $target:expr, $lvl:expr, $name:expr) => {
+ $crate::span!(target: $target, $lvl, $name,)
+ };
+ ($lvl:expr, $name:expr, $($fields:tt)*) => {
+ $crate::span!(
+ target: module_path!(),
+ $lvl,
+ $name,
+ $($fields)*
+ )
+ };
+ ($lvl:expr, $name:expr) => {
+ $crate::span!(
+ target: module_path!(),
+ $lvl,
+ $name,
+ )
+ };
+}
+
+/// Create an event with the given level.
+#[macro_export]
+macro_rules! event {
+ (target: $target:expr, $lvl:expr, { $($fields:tt)* } )=> (
+ {
+ static META: $crate::Metadata<'static> = {
+ $crate::metadata! {
+ name: concat!(
+ "event ",
+ file!(),
+ ":",
+ line!()
+ ),
+ target: $target,
+ level: $lvl,
+ fields: $crate::fieldset!( $($fields)* ),
+ callsite: &$crate::MetaOnlyCallsite(&META),
+ kind: $crate::metadata::Kind::EVENT,
+ }
+ };
+ $crate::Event::dispatch(
+ &META,
+ &$crate::valueset!(META.fields(), $($fields)*)
+ );
+ }
+ );
+ (target: $target:expr, $lvl:expr, { $($fields:tt)* }, $($arg:tt)+ ) => (
+ $crate::event!(
+ target: $target,
+ $lvl,
+ { message = format_args!($($arg)+), $($fields)* }
+ )
+ );
+ (target: $target:expr, $lvl:expr, $($k:ident).+ = $($fields:tt)* ) => (
+ $crate::event!(target: $target, $lvl, { $($k).+ = $($fields)* })
+ );
+ (target: $target:expr, $lvl:expr, $($arg:tt)+ ) => (
+ $crate::event!(target: $target, $lvl, { $($arg)+ })
+ );
+ ( $lvl:expr, { $($fields:tt)* }, $($arg:tt)+ ) => (
+ $crate::event!(
+ target: module_path!(),
+ $lvl,
+ { message = format_args!($($arg)+), $($fields)* }
+ )
+ );
+ ($lvl:expr, $($k:ident).+ = $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $lvl,
+ { $($k).+ = $($field)*}
+ )
+ );
+ ($lvl:expr, $($k:ident).+, $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $lvl,
+ { $($k).+, $($field)*}
+ )
+ );
+ ($lvl:expr, ?$($k:ident).+, $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $lvl,
+ { ?$($k).+, $($field)*}
+ )
+ );
+ ($lvl:expr, %$($k:ident).+, $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $lvl,
+ { %$($k).+, $($field)*}
+ )
+ );
+ ($lvl:expr, ?$($k:ident).+) => (
+ $crate::event!($lvl, ?$($k).+,)
+ );
+ ($lvl:expr, %$($k:ident).+) => (
+ $crate::event!($lvl, %$($k).+,)
+ );
+ ($lvl:expr, $($k:ident).+) => (
+ $crate::event!($lvl, $($k).+,)
+ );
+ ( $lvl:expr, $($arg:tt)+ ) => (
+ $crate::event!(target: module_path!(), $lvl, { $($arg)+ })
+ );
+}
+
+// Copied from`tracing`, would be nice to have it in `tracing-core`.
+#[doc(hidden)]
+#[macro_export]
+macro_rules! fieldset {
+ // == base case ==
+ (@ { $(,)* $($out:expr),* $(,)* } $(,)*) => {
+ &[ $($out),* ]
+ };
+
+ // == recursive cases (more tts) ==
+ (@ { $(,)* $($out:expr),* } $($k:ident).+ = ?$val:expr, $($rest:tt)*) => {
+ $crate::fieldset!(@ { $($out),*, stringify!($($k).+) } $($rest)*)
+ };
+ (@ { $(,)* $($out:expr),* } $($k:ident).+ = %$val:expr, $($rest:tt)*) => {
+ $crate::fieldset!(@ { $($out),*, stringify!($($k).+) } $($rest)*)
+ };
+ (@ { $(,)* $($out:expr),* } $($k:ident).+ = $val:expr, $($rest:tt)*) => {
+ $crate::fieldset!(@ { $($out),*, stringify!($($k).+) } $($rest)*)
+ };
+ // TODO(#1138): determine a new syntax for uninitialized span fields, and
+ // re-enable this.
+ // (@ { $($out:expr),* } $($k:ident).+ = _, $($rest:tt)*) => {
+ // $crate::fieldset!(@ { $($out),*, stringify!($($k).+) } $($rest)*)
+ // };
+ (@ { $(,)* $($out:expr),* } ?$($k:ident).+, $($rest:tt)*) => {
+ $crate::fieldset!(@ { $($out),*, stringify!($($k).+) } $($rest)*)
+ };
+ (@ { $(,)* $($out:expr),* } %$($k:ident).+, $($rest:tt)*) => {
+ $crate::fieldset!(@ { $($out),*, stringify!($($k).+) } $($rest)*)
+ };
+ (@ { $(,)* $($out:expr),* } $($k:ident).+, $($rest:tt)*) => {
+ $crate::fieldset!(@ { $($out),*, stringify!($($k).+) } $($rest)*)
+ };
+
+ // Handle literal names
+ (@ { $(,)* $($out:expr),* } $k:literal = ?$val:expr, $($rest:tt)*) => {
+ $crate::fieldset!(@ { $($out),*, $k } $($rest)*)
+ };
+ (@ { $(,)* $($out:expr),* } $k:literal = %$val:expr, $($rest:tt)*) => {
+ $crate::fieldset!(@ { $($out),*, $k } $($rest)*)
+ };
+ (@ { $(,)* $($out:expr),* } $k:literal = $val:expr, $($rest:tt)*) => {
+ $crate::fieldset!(@ { $($out),*, $k } $($rest)*)
+ };
+
+ // Remainder is unparseable, but exists --- must be format args!
+ (@ { $(,)* $($out:expr),* } $($rest:tt)+) => {
+ $crate::fieldset!(@ { "message", $($out),*, })
+ };
+
+ // == entry ==
+ ($($args:tt)*) => {
+ $crate::fieldset!(@ { } $($args)*,)
+ };
+}
+
+// Copied from`tracing`, would be nice to have it in `tracing-core`.
+#[doc(hidden)]
+#[macro_export]
+macro_rules! valueset {
+
+ // === base case ===
+ (@ { $(,)* $($val:expr),* $(,)* }, $next:expr $(,)*) => {
+ &[ $($val),* ]
+ };
+
+ // === recursive case (more tts) ===
+
+ // TODO(#1138): determine a new syntax for uninitialized span fields, and
+ // re-enable this.
+ // (@{ $(,)* $($out:expr),* }, $next:expr, $($k:ident).+ = _, $($rest:tt)*) => {
+ // $crate::valueset!(@ { $($out),*, (&$next, None) }, $next, $($rest)*)
+ // };
+ (@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+ = ?$val:expr, $($rest:tt)*) => {
+ $crate::valueset!(
+ @ { $($out),*, (&$next, Some(&debug(&$val) as &dyn Value)) },
+ $next,
+ $($rest)*
+ )
+ };
+ (@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+ = %$val:expr, $($rest:tt)*) => {
+ $crate::valueset!(
+ @ { $($out),*, (&$next, Some(&display(&$val) as &dyn Value)) },
+ $next,
+ $($rest)*
+ )
+ };
+ (@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+ = $val:expr, $($rest:tt)*) => {
+ $crate::valueset!(
+ @ { $($out),*, (&$next, Some(&$val as &dyn Value)) },
+ $next,
+ $($rest)*
+ )
+ };
+ (@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+, $($rest:tt)*) => {
+ $crate::valueset!(
+ @ { $($out),*, (&$next, Some(&$($k).+ as &dyn Value)) },
+ $next,
+ $($rest)*
+ )
+ };
+ (@ { $(,)* $($out:expr),* }, $next:expr, ?$($k:ident).+, $($rest:tt)*) => {
+ $crate::valueset!(
+ @ { $($out),*, (&$next, Some(&debug(&$($k).+) as &dyn Value)) },
+ $next,
+ $($rest)*
+ )
+ };
+ (@ { $(,)* $($out:expr),* }, $next:expr, %$($k:ident).+, $($rest:tt)*) => {
+ $crate::valueset!(
+ @ { $($out),*, (&$next, Some(&display(&$($k).+) as &dyn Value)) },
+ $next,
+ $($rest)*
+ )
+ };
+ (@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+ = ?$val:expr) => {
+ $crate::valueset!(
+ @ { $($out),*, (&$next, Some(&debug(&$val) as &dyn Value)) },
+ $next,
+ )
+ };
+ (@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+ = %$val:expr) => {
+ $crate::valueset!(
+ @ { $($out),*, (&$next, Some(&display(&$val) as &dyn Value)) },
+ $next,
+ )
+ };
+ (@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+ = $val:expr) => {
+ $crate::valueset!(
+ @ { $($out),*, (&$next, Some(&$val as &dyn Value)) },
+ $next,
+ )
+ };
+ (@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+) => {
+ $crate::valueset!(
+ @ { $($out),*, (&$next, Some(&$($k).+ as &dyn Value)) },
+ $next,
+ )
+ };
+ (@ { $(,)* $($out:expr),* }, $next:expr, ?$($k:ident).+) => {
+ $crate::valueset!(
+ @ { $($out),*, (&$next, Some(&debug(&$($k).+) as &dyn Value)) },
+ $next,
+ )
+ };
+ (@ { $(,)* $($out:expr),* }, $next:expr, %$($k:ident).+) => {
+ $crate::valueset!(
+ @ { $($out),*, (&$next, Some(&display(&$($k).+) as &dyn Value)) },
+ $next,
+ )
+ };
+
+ // Handle literal names
+ (@ { $(,)* $($out:expr),* }, $next:expr, $k:literal = ?$val:expr, $($rest:tt)*) => {
+ $crate::valueset!(
+ @ { $($out),*, (&$next, Some(&debug(&$val) as &dyn Value)) },
+ $next,
+ $($rest)*
+ )
+ };
+ (@ { $(,)* $($out:expr),* }, $next:expr, $k:literal = %$val:expr, $($rest:tt)*) => {
+ $crate::valueset!(
+ @ { $($out),*, (&$next, Some(&display(&$val) as &dyn Value)) },
+ $next,
+ $($rest)*
+ )
+ };
+ (@ { $(,)* $($out:expr),* }, $next:expr, $k:literal = $val:expr, $($rest:tt)*) => {
+ $crate::valueset!(
+ @ { $($out),*, (&$next, Some(&$val as &dyn Value)) },
+ $next,
+ $($rest)*
+ )
+ };
+ (@ { $(,)* $($out:expr),* }, $next:expr, $k:literal = ?$val:expr) => {
+ $crate::valueset!(
+ @ { $($out),*, (&$next, Some(&debug(&$val) as &dyn Value)) },
+ $next,
+ )
+ };
+ (@ { $(,)* $($out:expr),* }, $next:expr, $k:literal = %$val:expr) => {
+ $crate::valueset!(
+ @ { $($out),*, (&$next, Some(&display(&$val) as &dyn Value)) },
+ $next,
+ )
+ };
+ (@ { $(,)* $($out:expr),* }, $next:expr, $k:literal = $val:expr) => {
+ $crate::valueset!(
+ @ { $($out),*, (&$next, Some(&$val as &dyn Value)) },
+ $next,
+ )
+ };
+
+ // Remainder is unparsable, but exists --- must be format args!
+ (@ { $(,)* $($out:expr),* }, $next:expr, $($rest:tt)+) => {
+ $crate::valueset!(@ { (&$next, Some(&format_args!($($rest)+) as &dyn Value)), $($out),* }, $next, )
+ };
+
+ // === entry ===
+ ($fields:expr, $($kvs:tt)+) => {
+ {
+ #[allow(unused_imports)]
+ use $crate::field::{debug, display, Value};
+ let mut iter = $fields.iter();
+ $fields.value_set($crate::valueset!(
+ @ { },
+ iter.next().expect("FieldSet corrupted (this is a bug)"),
+ $($kvs)+
+ ))
+ }
+ };
+ ($fields:expr,) => {
+ {
+ $fields.value_set(&[])
+ }
+ };
+}
diff --git a/vendor/gix-trace/src/lib.rs b/vendor/gix-trace/src/lib.rs
new file mode 100644
index 000000000..ab9409534
--- /dev/null
+++ b/vendor/gix-trace/src/lib.rs
@@ -0,0 +1,632 @@
+//! A crate providing macros for creating spans in various detail levels. `coarse!` shoudl be used for top-level operations, whereas
+//! `detail!` should be used in plumbing crates unless their operations are likely to cost a lot of time.
+//!
+//! The application is supposed to explicitly turn on tracing via `gix-features`.
+//! Crates that use `gix-features` should use `gix_features::trace`, and those who don't can use `gix_trace` directly.
+//! ## Feature Flags
+#![cfg_attr(
+ feature = "document-features",
+ cfg_attr(doc, doc = ::document_features::document_features!())
+)]
+#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
+#![deny(missing_docs, rust_2018_idioms, unsafe_code)]
+
+/// The level at which the tracing item should be created.
+///
+/// It's used to filter items early.
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)]
+pub enum Level {
+ /// A coarse-grained trace level, one that should span entire operations with low frequency.
+ Coarse = 1,
+ /// Finer grained trace level that further subdivides coarse-level traces.
+ ///
+ /// Note that these should only be created for areas of the code which have significant cost.
+ Detail = 2,
+}
+
+/// The maximum allowed level for tracing items, as compiled in.
+#[cfg(feature = "tracing-detail")]
+pub const MAX_LEVEL: Level = Level::Detail;
+/// The maximum allowed level for tracing items, as compiled in.
+#[cfg(not(feature = "tracing-detail"))]
+pub const MAX_LEVEL: Level = Level::Coarse;
+
+#[cfg(feature = "tracing")]
+mod enabled;
+
+#[cfg(feature = "tracing")]
+pub use enabled::{field, Span};
+
+impl Span {
+ /// Execute `f` in with this span active, consuming it.
+ pub fn into_scope<T>(self, f: impl FnOnce() -> T) -> T {
+ f()
+ }
+}
+
+#[cfg(feature = "tracing")]
+#[doc(hidden)]
+pub use enabled::{metadata, Event, MetaOnlyCallsite, Metadata};
+
+#[cfg(not(feature = "tracing"))]
+mod disabled;
+#[cfg(not(feature = "tracing"))]
+pub use disabled::Span;
+
+///
+pub mod event {
+ #[cfg(feature = "tracing")]
+ pub use tracing_core::Level;
+
+ /// All available tracing levels for use in `event!()` macro.
+ #[cfg(not(feature = "tracing"))]
+ #[repr(usize)]
+ #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
+ pub enum Level {
+ /// The "trace" level.
+ ///
+ /// Designates very low priority, often extremely verbose, information.
+ TRACE = 0,
+ /// The "debug" level.
+ ///
+ /// Designates lower priority information.
+ DEBUG = 1,
+ /// The "info" level.
+ ///
+ /// Designates useful information.
+ INFO = 2,
+ /// The "warn" level.
+ ///
+ /// Designates hazardous situations.
+ WARN = 3,
+ /// The "error" level.
+ ///
+ /// Designates very serious errors.
+ ERROR = 4,
+ }
+}
+
+/// Create a new [coarse][Level::Coarse] span.
+#[macro_export]
+macro_rules! coarse {
+ (target: $target:expr, $name:expr, $($field:tt)*) => {
+ $crate::span!(
+ target: $target,
+ $crate::Level::Coarse,
+ $name,
+ $($field)*
+ )
+ };
+ (target: $target:expr, $name:expr) => {
+ $crate::coarse!(target: $target, $name,)
+ };
+ ($name:expr, $($field:tt)*) => {
+ $crate::span!(
+ target: module_path!(),
+ $crate::Level::Coarse,
+ $name,
+ $($field)*
+ )
+ };
+ ($name:expr) => {$crate::coarse!($name,)};
+}
+
+/// Create a new [detail][Level::Detail] span.
+#[macro_export]
+macro_rules! detail {
+ (target: $target:expr, $name:expr, $($field:tt)*) => {
+ $crate::span!(
+ target: $target,
+ $crate::Level::Detail,
+ $name,
+ $($field)*
+ )
+ };
+ (target: $target:expr, $name:expr) => {
+ $crate::detail!(target: $target, $name,)
+ };
+ ($name:expr, $($field:tt)*) => {
+ $crate::span!(
+ target: module_path!(),
+ $crate::Level::Detail,
+ $name,
+ $($field)*
+ )
+ };
+ ($name:expr) => {$crate::coarse!($name,)};
+}
+
+/// Emit an error event.
+#[macro_export]
+macro_rules! error {
+ (target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) => (
+ $crate::event!(target: $target, $crate::event::Level::ERROR, { $($field)* }, $($arg)*)
+ );
+ (target: $target:expr, $($k:ident).+ $($field:tt)* ) => (
+ $crate::event!(target: $target, $crate::event::Level::ERROR, { $($k).+ $($field)* })
+ );
+ (target: $target:expr, ?$($k:ident).+ $($field:tt)* ) => (
+ $crate::event!(target: $target, $crate::event::Level::ERROR, { ?$($k).+ $($field)* })
+ );
+ (target: $target:expr, %$($k:ident).+ $($field:tt)* ) => (
+ $crate::event!(target: $target, $crate::event::Level::ERROR, { %$($k).+ $($field)* })
+ );
+ (target: $target:expr, $($arg:tt)+ ) => (
+ $crate::event!(target: $target, $crate::event::Level::ERROR, {}, $($arg)+)
+ );
+ ({ $($field:tt)+ }, $($arg:tt)+ ) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::ERROR,
+ { $($field)+ },
+ $($arg)+
+ )
+ );
+ ($($k:ident).+ = $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::ERROR,
+ { $($k).+ = $($field)*}
+ )
+ );
+ (?$($k:ident).+ = $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::ERROR,
+ { ?$($k).+ = $($field)*}
+ )
+ );
+ (%$($k:ident).+ = $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::ERROR,
+ { %$($k).+ = $($field)*}
+ )
+ );
+ ($($k:ident).+, $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::ERROR,
+ { $($k).+, $($field)*}
+ )
+ );
+ (?$($k:ident).+, $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::ERROR,
+ { ?$($k).+, $($field)*}
+ )
+ );
+ (%$($k:ident).+, $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::ERROR,
+ { %$($k).+, $($field)*}
+ )
+ );
+ (?$($k:ident).+) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::ERROR,
+ { ?$($k).+ }
+ )
+ );
+ (%$($k:ident).+) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::ERROR,
+ { %$($k).+ }
+ )
+ );
+ ($($k:ident).+) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::ERROR,
+ { $($k).+ }
+ )
+ );
+ ($($arg:tt)+) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::ERROR,
+ {},
+ $($arg)+
+ )
+ );
+}
+
+/// Emit a warn event.
+#[macro_export]
+macro_rules! warn {
+ (target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) => (
+ $crate::event!(target: $target, $crate::event::Level::WARN, { $($field)* }, $($arg)*)
+ );
+ (target: $target:expr, $($k:ident).+ $($field:tt)* ) => (
+ $crate::event!(target: $target, $crate::event::Level::WARN, { $($k).+ $($field)* })
+ );
+ (target: $target:expr, ?$($k:ident).+ $($field:tt)* ) => (
+ $crate::event!(target: $target, $crate::event::Level::WARN, { ?$($k).+ $($field)* })
+ );
+ (target: $target:expr, %$($k:ident).+ $($field:tt)* ) => (
+ $crate::event!(target: $target, $crate::event::Level::WARN, { %$($k).+ $($field)* })
+ );
+ (target: $target:expr, $($arg:tt)+ ) => (
+ $crate::event!(target: $target, $crate::event::Level::WARN, {}, $($arg)+)
+ );
+ ({ $($field:tt)+ }, $($arg:tt)+ ) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::WARN,
+ { $($field)+ },
+ $($arg)+
+ )
+ );
+ ($($k:ident).+ = $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::WARN,
+ { $($k).+ = $($field)*}
+ )
+ );
+ (?$($k:ident).+ = $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::WARN,
+ { ?$($k).+ = $($field)*}
+ )
+ );
+ (%$($k:ident).+ = $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::WARN,
+ { %$($k).+ = $($field)*}
+ )
+ );
+ ($($k:ident).+, $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::WARN,
+ { $($k).+, $($field)*}
+ )
+ );
+ (?$($k:ident).+, $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::WARN,
+ { ?$($k).+, $($field)*}
+ )
+ );
+ (%$($k:ident).+, $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::WARN,
+ { %$($k).+, $($field)*}
+ )
+ );
+ (?$($k:ident).+) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::WARN,
+ { ?$($k).+ }
+ )
+ );
+ (%$($k:ident).+) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::WARN,
+ { %$($k).+ }
+ )
+ );
+ ($($k:ident).+) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::WARN,
+ { $($k).+ }
+ )
+ );
+ ($($arg:tt)+) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::WARN,
+ {},
+ $($arg)+
+ )
+ );
+}
+
+/// Emit an info event.
+#[macro_export]
+macro_rules! info {
+ (target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) => (
+ $crate::event!(target: $target, $crate::event::Level::INFO, { $($field)* }, $($arg)*)
+ );
+ (target: $target:expr, $($k:ident).+ $($field:tt)* ) => (
+ $crate::event!(target: $target, $crate::event::Level::INFO, { $($k).+ $($field)* })
+ );
+ (target: $target:expr, ?$($k:ident).+ $($field:tt)* ) => (
+ $crate::event!(target: $target, $crate::event::Level::INFO, { ?$($k).+ $($field)* })
+ );
+ (target: $target:expr, %$($k:ident).+ $($field:tt)* ) => (
+ $crate::event!(target: $target, $crate::event::Level::INFO, { %$($k).+ $($field)* })
+ );
+ (target: $target:expr, $($arg:tt)+ ) => (
+ $crate::event!(target: $target, $crate::event::Level::INFO, {}, $($arg)+)
+ );
+ ({ $($field:tt)+ }, $($arg:tt)+ ) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::INFO,
+ { $($field)+ },
+ $($arg)+
+ )
+ );
+ ($($k:ident).+ = $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::INFO,
+ { $($k).+ = $($field)*}
+ )
+ );
+ (?$($k:ident).+ = $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::INFO,
+ { ?$($k).+ = $($field)*}
+ )
+ );
+ (%$($k:ident).+ = $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::INFO,
+ { %$($k).+ = $($field)*}
+ )
+ );
+ ($($k:ident).+, $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::INFO,
+ { $($k).+, $($field)*}
+ )
+ );
+ (?$($k:ident).+, $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::INFO,
+ { ?$($k).+, $($field)*}
+ )
+ );
+ (%$($k:ident).+, $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::INFO,
+ { %$($k).+, $($field)*}
+ )
+ );
+ (?$($k:ident).+) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::INFO,
+ { ?$($k).+ }
+ )
+ );
+ (%$($k:ident).+) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::INFO,
+ { %$($k).+ }
+ )
+ );
+ ($($k:ident).+) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::INFO,
+ { $($k).+ }
+ )
+ );
+ ($($arg:tt)+) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::INFO,
+ {},
+ $($arg)+
+ )
+ );
+}
+
+/// Emit a debug event.
+#[macro_export]
+macro_rules! debug {
+ (target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) => (
+ $crate::event!(target: $target, $crate::event::Level::DEBUG, { $($field)* }, $($arg)*)
+ );
+ (target: $target:expr, $($k:ident).+ $($field:tt)* ) => (
+ $crate::event!(target: $target, $crate::event::Level::DEBUG, { $($k).+ $($field)* })
+ );
+ (target: $target:expr, ?$($k:ident).+ $($field:tt)* ) => (
+ $crate::event!(target: $target, $crate::event::Level::DEBUG, { ?$($k).+ $($field)* })
+ );
+ (target: $target:expr, %$($k:ident).+ $($field:tt)* ) => (
+ $crate::event!(target: $target, $crate::event::Level::DEBUG, { %$($k).+ $($field)* })
+ );
+ (target: $target:expr, $($arg:tt)+ ) => (
+ $crate::event!(target: $target, $crate::event::Level::DEBUG, {}, $($arg)+)
+ );
+ ({ $($field:tt)+ }, $($arg:tt)+ ) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::DEBUG,
+ { $($field)+ },
+ $($arg)+
+ )
+ );
+ ($($k:ident).+ = $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::DEBUG,
+ { $($k).+ = $($field)*}
+ )
+ );
+ (?$($k:ident).+ = $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::DEBUG,
+ { ?$($k).+ = $($field)*}
+ )
+ );
+ (%$($k:ident).+ = $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::DEBUG,
+ { %$($k).+ = $($field)*}
+ )
+ );
+ ($($k:ident).+, $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::DEBUG,
+ { $($k).+, $($field)*}
+ )
+ );
+ (?$($k:ident).+, $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::DEBUG,
+ { ?$($k).+, $($field)*}
+ )
+ );
+ (%$($k:ident).+, $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::DEBUG,
+ { %$($k).+, $($field)*}
+ )
+ );
+ (?$($k:ident).+) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::DEBUG,
+ { ?$($k).+ }
+ )
+ );
+ (%$($k:ident).+) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::DEBUG,
+ { %$($k).+ }
+ )
+ );
+ ($($k:ident).+) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::DEBUG,
+ { $($k).+ }
+ )
+ );
+ ($($arg:tt)+) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::DEBUG,
+ {},
+ $($arg)+
+ )
+ );
+}
+
+/// Emit a trace event.
+#[macro_export]
+macro_rules! trace {
+ (target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) => (
+ $crate::event!(target: $target, $crate::event::Level::TRACE, { $($field)* }, $($arg)*)
+ );
+ (target: $target:expr, $($k:ident).+ $($field:tt)* ) => (
+ $crate::event!(target: $target, $crate::event::Level::TRACE, { $($k).+ $($field)* })
+ );
+ (target: $target:expr, ?$($k:ident).+ $($field:tt)* ) => (
+ $crate::event!(target: $target, $crate::event::Level::TRACE, { ?$($k).+ $($field)* })
+ );
+ (target: $target:expr, %$($k:ident).+ $($field:tt)* ) => (
+ $crate::event!(target: $target, $crate::event::Level::TRACE, { %$($k).+ $($field)* })
+ );
+ (target: $target:expr, $($arg:tt)+ ) => (
+ $crate::event!(target: $target, $crate::event::Level::TRACE, {}, $($arg)+)
+ );
+ ({ $($field:tt)+ }, $($arg:tt)+ ) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::TRACE,
+ { $($field)+ },
+ $($arg)+
+ )
+ );
+ ($($k:ident).+ = $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::TRACE,
+ { $($k).+ = $($field)*}
+ )
+ );
+ (?$($k:ident).+ = $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::TRACE,
+ { ?$($k).+ = $($field)*}
+ )
+ );
+ (%$($k:ident).+ = $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::TRACE,
+ { %$($k).+ = $($field)*}
+ )
+ );
+ ($($k:ident).+, $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::TRACE,
+ { $($k).+, $($field)*}
+ )
+ );
+ (?$($k:ident).+, $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::TRACE,
+ { ?$($k).+, $($field)*}
+ )
+ );
+ (%$($k:ident).+, $($field:tt)*) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::TRACE,
+ { %$($k).+, $($field)*}
+ )
+ );
+ (?$($k:ident).+) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::TRACE,
+ { ?$($k).+ }
+ )
+ );
+ (%$($k:ident).+) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::TRACE,
+ { %$($k).+ }
+ )
+ );
+ ($($k:ident).+) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::TRACE,
+ { $($k).+ }
+ )
+ );
+ ($($arg:tt)+) => (
+ $crate::event!(
+ target: module_path!(),
+ $crate::event::Level::TRACE,
+ {},
+ $($arg)+
+ )
+ );
+}