-
Notifications
You must be signed in to change notification settings - Fork 4
Use macro wrappers for feature-gated tracing macros, turning all of them "off" by default
#270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
93fd090
feat: use trace_warn and trace_info
LeoPatOZ 483815e
feat: use trace_error
LeoPatOZ ad6128f
fix: clippy warnings
LeoPatOZ 4457068
ref: trace -> opt
LeoPatOZ fb476a7
feat: use opt debug
LeoPatOZ 66c432c
ref: warn to opt warn
LeoPatOZ 1267301
ref: use opt trace
LeoPatOZ a358e7b
ref: remove import
LeoPatOZ 773c139
fix: remainding clippy warnings
LeoPatOZ a5b9189
fix: fmt
LeoPatOZ 8cfad38
fix: clippy by allowing _ binding
LeoPatOZ 8dc8990
tracing fixes proposal
0xNeshi eb1c99d
make logging module internal
0xNeshi 88c294e
fixes
0xNeshi 1433261
Merge branch 'main' into tracing-fixes
0xNeshi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -74,3 +74,4 @@ workspace = true | |
|
|
||
| [features] | ||
| test-utils = [] | ||
| tracing = [] | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,104 @@ | ||
| #[cfg(feature = "tracing")] | ||
| #[allow(unused_macros)] | ||
| macro_rules! error { | ||
| ($($arg:tt)*) => { | ||
| tracing::error!($($arg)*) | ||
| }; | ||
| } | ||
|
|
||
| #[cfg(not(feature = "tracing"))] | ||
| #[allow(unused_macros)] | ||
| macro_rules! error { | ||
| ($($arg:tt)*) => { | ||
| $crate::__trace_consume!($($arg)*) | ||
| }; | ||
| } | ||
|
|
||
| #[cfg(feature = "tracing")] | ||
| #[allow(unused_macros)] | ||
| macro_rules! warn { | ||
| ($($arg:tt)*) => { | ||
| tracing::warn!($($arg)*) | ||
| }; | ||
| } | ||
|
|
||
| #[cfg(not(feature = "tracing"))] | ||
| #[allow(unused_macros)] | ||
| macro_rules! warn { | ||
| ($($arg:tt)*) => { | ||
| $crate::__trace_consume!($($arg)*) | ||
| }; | ||
| } | ||
|
|
||
| #[cfg(feature = "tracing")] | ||
| #[allow(unused_macros)] | ||
| macro_rules! info { | ||
| ($($arg:tt)*) => { | ||
| tracing::info!($($arg)*) | ||
| }; | ||
| } | ||
|
|
||
| #[cfg(not(feature = "tracing"))] | ||
| #[allow(unused_macros)] | ||
| macro_rules! info { | ||
| ($($arg:tt)*) => { | ||
| $crate::__trace_consume!($($arg)*) | ||
| }; | ||
| } | ||
|
|
||
| #[cfg(feature = "tracing")] | ||
| #[allow(unused_macros)] | ||
| macro_rules! debug { | ||
| ($($arg:tt)*) => { | ||
| tracing::debug!($($arg)*) | ||
| }; | ||
| } | ||
|
|
||
| #[cfg(not(feature = "tracing"))] | ||
| #[allow(unused_macros)] | ||
| macro_rules! debug { | ||
| ($($arg:tt)*) => { | ||
| $crate::__trace_consume!($($arg)*) | ||
| }; | ||
| } | ||
|
|
||
| #[cfg(feature = "tracing")] | ||
| #[allow(unused_macros)] | ||
| macro_rules! trace { | ||
| ($($arg:tt)*) => { | ||
| tracing::trace!($($arg)*) | ||
| }; | ||
| } | ||
|
|
||
| #[cfg(not(feature = "tracing"))] | ||
| #[allow(unused_macros)] | ||
| macro_rules! trace { | ||
| ($($arg:tt)*) => { | ||
| $crate::__trace_consume!($($arg)*) | ||
| }; | ||
| } | ||
|
|
||
| #[doc(hidden)] | ||
| #[macro_export] | ||
| #[cfg(not(feature = "tracing"))] | ||
| #[allow(unused_macros)] | ||
| macro_rules! __trace_consume { | ||
0xNeshi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // field = %expr, rest... | ||
| ($field:ident = % $value:expr, $($rest:tt)*) => { | ||
| { let _ = &$value; $crate::__trace_consume!($($rest)*); } | ||
| }; | ||
| // field = ?expr, rest... | ||
| ($field:ident = ? $value:expr, $($rest:tt)*) => { | ||
| { let _ = &$value; $crate::__trace_consume!($($rest)*); } | ||
| }; | ||
| // field = expr, rest... | ||
| ($field:ident = $value:expr, $($rest:tt)*) => { | ||
| { let _ = &$value; $crate::__trace_consume!($($rest)*); } | ||
| }; | ||
| // String literal or other tokens - ignore | ||
| ($lit:literal $($rest:tt)*) => { | ||
| $crate::__trace_consume!($($rest)*) | ||
| }; | ||
| // Base case - empty | ||
| () => {}; | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| use std::fmt::Debug; | ||
|
|
||
| use tokio::sync::mpsc; | ||
| use tracing::{info, warn}; | ||
|
|
||
| use crate::ScannerError; | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.