mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-07 00:00:08 +02:00
trace: Remove default trace level and make levels mandatory on span! macro (#1025)
## Motivation Was determined that having the span! macro default to the TRACE level is probably not ideal (see discussion on #952). Closes #1013 ## Solution Remove default trace level and make log lvl mandatory on span! macro, and add the respective `trace_span!`, `debug_span!`, `info_span!`, `warn_span!` and `error_span!` macros that behave as span! macro, but with defined log levels ## Notes I think this is it, also removed some captures that were repeated, and some testcases that also seemed repeated after adding the mandatory log level, but please review it, if more tests or examples are needed happy to provide (tried to find a way to get the generated macros log level, but didn't find one, if there is a way i can add tests to assert that the generated macro has the matching log level ). thanks
This commit is contained in:
committed by
Eliza Weisman
parent
599955f716
commit
597f271c08
@@ -12,9 +12,10 @@
|
||||
//! if the span exists:
|
||||
//! ```
|
||||
//! # #[macro_use] extern crate tokio_trace;
|
||||
//! # use tokio_trace::Level;
|
||||
//! # fn main() {
|
||||
//! let my_var: u64 = 5;
|
||||
//! let mut my_span = span!("my_span", my_var = &my_var);
|
||||
//! let mut my_span = span!(Level::TRACE, "my_span", my_var = &my_var);
|
||||
//!
|
||||
//! my_span.enter(|| {
|
||||
//! // perform some work in the context of `my_span`...
|
||||
@@ -78,9 +79,10 @@
|
||||
//! exists. For example:
|
||||
//! ```
|
||||
//! # #[macro_use] extern crate tokio_trace;
|
||||
//! # use tokio_trace::Level;
|
||||
//! # fn main() {
|
||||
//! {
|
||||
//! span!("my_span").enter(|| {
|
||||
//! span!(Level::TRACE, "my_span").enter(|| {
|
||||
//! // perform some work in the context of `my_span`...
|
||||
//! }); // --> Subscriber::exit(my_span)
|
||||
//!
|
||||
@@ -96,10 +98,11 @@
|
||||
//! time it is exited. For example:
|
||||
//! ```
|
||||
//! # #[macro_use] extern crate tokio_trace;
|
||||
//! # use tokio_trace::Level;
|
||||
//! # fn main() {
|
||||
//! use tokio_trace::Span;
|
||||
//!
|
||||
//! let my_span = span!("my_span");
|
||||
//! let my_span = span!(Level::TRACE, "my_span");
|
||||
//! // Drop the handle to the span.
|
||||
//! drop(my_span); // --> Subscriber::drop_span(my_span)
|
||||
//! # }
|
||||
|
||||
Reference in New Issue
Block a user