forked from hyperium/hyper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(trace): add internal tracing macro module
Introduce several macros that act as wrappers around the `tracing` module's macros to allow for more concise syntax for conditional compilation of `tracing` macro calls. As `tracing` is unstable, the new `trace` module will facilitate transitioning `tracing` to an optional feature, as outlined in hyperium#2874 and hyperium#3326. BREAKING CHANGES: Integration of macros requires the replacement of uses of `trace` macros.
- Loading branch information
Showing
2 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#![allow(unused_macros)] | ||
|
||
macro_rules! debug { | ||
($($arg:tt)+) => { | ||
#[cfg(feature = "tracing")] | ||
{ | ||
println!($($arg)+); | ||
tracing::debug!($($arg)+); | ||
} | ||
} | ||
} | ||
|
||
macro_rules! debug_span { | ||
($($arg:tt)*) => { | ||
#[cfg(feature = "tracing")] | ||
{ | ||
let span = tracing::debug_span!($($arg)+); | ||
let _ = span.enter(); | ||
} | ||
} | ||
} | ||
|
||
macro_rules! error { | ||
($($arg:tt)*) => { | ||
#[cfg(feature = "tracing")] | ||
{ | ||
tracing::error!($($arg)+); | ||
} | ||
} | ||
} | ||
|
||
macro_rules! error_span { | ||
($($arg:tt)*) => { | ||
#[cfg(feature = "tracing")] | ||
{ | ||
let span = tracing::error_span!($($arg)+); | ||
let _ = span.enter(); | ||
} | ||
} | ||
} | ||
|
||
macro_rules! info { | ||
($($arg:tt)*) => { | ||
#[cfg(feature = "tracing")] | ||
{ | ||
tracing::info!($($arg)+); | ||
} | ||
} | ||
} | ||
|
||
macro_rules! info_span { | ||
($($arg:tt)*) => { | ||
#[cfg(feature = "tracing")] | ||
{ | ||
let span = tracing::info_span!($($arg)+); | ||
let _ = span.enter(); | ||
} | ||
} | ||
} | ||
|
||
macro_rules! trace { | ||
($($arg:tt)*) => { | ||
#[cfg(feature = "tracing")] | ||
{ | ||
tracing::trace!($($arg)+); | ||
} | ||
} | ||
} | ||
|
||
macro_rules! trace_span { | ||
($($arg:tt)*) => { | ||
#[cfg(feature = "tracing")] | ||
{ | ||
let span = tracing::trace_span!($($arg)+); | ||
let _ = span.enter(); | ||
} | ||
} | ||
} | ||
|
||
macro_rules! span { | ||
($($arg:tt)*) => { | ||
#[cfg(feature = "tracing")] | ||
{ | ||
let span = tracing::span!($($arg)+); | ||
let _ = span.enter(); | ||
} | ||
} | ||
} | ||
|
||
macro_rules! warn { | ||
($($arg:tt)*) => { | ||
#[cfg(feature = "tracing")] | ||
{ | ||
tracing::warn!($($arg)+); | ||
} | ||
} | ||
} | ||
|
||
macro_rules! warn_span { | ||
($($arg:tt)*) => { | ||
#[cfg(feature = "tracing")] | ||
{ | ||
let span = tracing::warn_span!($($arg)+); | ||
let _ = span.enter(); | ||
} | ||
} | ||
} |