Skip to content

Commit e8f6d93

Browse files
authored
test span / log syntax examples, make them consistent (#69)
1 parent 86cfa60 commit e8f6d93

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

src/macros/impl_.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ macro_rules! __log {
304304
$crate::__bind_single_ident_args!($($($path).+ $(= $value)?),*);
305305
$crate::__macros_impl::export_log_span(
306306
$format,
307-
$parent,
307+
&$parent,
308308
format!($format),
309309
$level,
310310
$crate::__json_schema!($($($path).+),*),

src/macros/mod.rs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ pub mod __macros_impl;
1212
///
1313
/// The macro accepts the following syntax:
1414
///
15-
/// ```rust,ignore
16-
/// span!(
17-
/// parent: tracing::Span, // optional, can emit this
18-
/// level: tracing::Level, // optional
19-
/// "format string", // required, must be a format string accepted by `format!()`
20-
/// attr = value, // optional attributes, can be repeated
21-
/// .. // as many additional attr = value pairs as desired
22-
/// )
15+
/// ```rust
16+
/// # let value = 42;
17+
/// logfire::span!(
18+
/// parent: tracing::Span::current(), // optional, tracing::Span
19+
/// level: tracing::Level::INFO, // optional, tracing::Level
20+
/// "format string", // required, must be a format string accepted by `format!()`
21+
/// attr = value, // optional, attribute key and value pair
22+
/// // .. // as many additional attr = value pairs as desired
23+
/// );
2324
/// ```
2425
///
2526
/// ## Attributes
@@ -28,7 +29,7 @@ pub mod __macros_impl;
2829
///
2930
/// `dotted.name = value` is also supported (and encouraged by Opentelemetry) to namespace
3031
/// attributes. However, dotted names are not supported in Rust format strings.
31-
//
32+
///
3233
/// ## Formatting
3334
///
3435
/// The format string only accepts arguments by name. These can either be explicitly passed
@@ -157,14 +158,15 @@ macro_rules! debug {
157158
///
158159
/// The macro accepts the following syntax:
159160
///
160-
/// ```rust,ignore
161-
/// log!(
162-
/// parent: tracing::Span, // optional, can emit this
163-
/// tracing::Level, // required, see `info!` and variants for convenience
164-
/// "format string", // required, must be a format string accepted by `format!()`
165-
/// attr = value, // optional attributes, can be repeated
166-
/// .. // as many additional arg = value pairs as desired
167-
/// )
161+
/// ```rust
162+
/// # let value = 42;
163+
/// logfire::log!(
164+
/// parent: tracing::Span::current(), // optional, tracing::Span
165+
/// tracing::Level::INFO, // required, see `info!` and variants for convenience
166+
/// "format string", // required, must be a format string accepted by `format!()`
167+
/// attr = value, // optional, attribute key and value pair
168+
/// // .. // as many additional attr = value pairs as desired
169+
/// );
168170
/// ```
169171
///
170172
/// ## Attributes
@@ -250,6 +252,6 @@ macro_rules! log {
250252
$crate::__macros_impl::log!(parent: $parent, $level, $format, $($($path).+ $(= $value)?),*)
251253
};
252254
($level:expr, $format:expr $(, $($path:ident).+ $(= $value:expr)?)* $(,)?) => {
253-
$crate::__macros_impl::log!(parent: &tracing::Span::current(), $level, $format, $($($path).+ $(= $value)?),*)
255+
$crate::__macros_impl::log!(parent: tracing::Span::current(), $level, $format, $($($path).+ $(= $value)?),*)
254256
};
255257
}

0 commit comments

Comments
 (0)