Skip to content
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

- remove default trace level and make log lvl mandatory on span! macro #1025

Merged
merged 1 commit into from
Apr 2, 2019

Conversation

jxs
Copy link
Member

@jxs jxs commented Mar 31, 2019

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

@jxs jxs force-pushed the update-trace-macros branch 3 times, most recently from 89ffd06 to 0e92f19 Compare March 31, 2019 12:34
Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good start, thanks! After you make the changes I've requested, I think this is good to merge.

tokio-trace/src/macros.rs Outdated Show resolved Hide resolved
tokio-trace/test-log-support/tests/log_no_trace.rs Outdated Show resolved Hide resolved
tokio-trace/src/span.rs Outdated Show resolved Hide resolved
@jxs jxs force-pushed the update-trace-macros branch from 0e92f19 to dc16dd4 Compare April 1, 2019 23:14
- add trace_span!, debug_span!, info_span!, warn_span! and error_span!
macros that behave as span! macro, but with defined log levels
@jxs jxs force-pushed the update-trace-macros branch from dc16dd4 to c92aa08 Compare April 1, 2019 23:18
@jxs
Copy link
Member Author

jxs commented Apr 1, 2019

ok updated it!

Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me!

I think that there are potentially some places where it might be good to the new macros in examples or tests rather than using span! with a level, just so that users see the new macros in use in more cases. But, I'm willing to merge this without making that change.

error_span!("foo", bar = 2, baz = 3);
error_span!("foo", bar = 2, baz = 4,);
error_span!("bar");
error_span!("bar",);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these tests have gotten so repetitive, part of me wonders if we should be generating them with a macro. But since the purpose of these tests is to catch any macro compilation errors, that's probably a mistake...

@jxs
Copy link
Member Author

jxs commented Apr 2, 2019

I think that there are potentially some places where it might be good to the new macros in examples or tests rather than using span! with a level, just so that users see the new macros in use in more cases. But, I'm willing to merge this without making that change.

I can make another PR with those changes, no problem, do you want to open an issue to track those cases?

@hawkw
Copy link
Member

hawkw commented Apr 2, 2019

@jxs sure! Also, another follow-up is that it would be great if after this PR merges, we update the crates in the tokio-trace-nursery repository which may be broken by this change. Is that something you'd be willing to do?

@hawkw hawkw merged commit 597f271 into tokio-rs:master Apr 2, 2019
@jxs
Copy link
Member Author

jxs commented Apr 2, 2019

yes sure! i am going to clone the repo and check which ones fail to build

@hawkw hawkw added this to the tokio-trace v0.1 milestone Apr 2, 2019
hawkw pushed a commit that referenced this pull request Jun 25, 2019
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

trace: Remove default level from span! macro
3 participants