Add feature to print line number#1804
Closed
pmnoxx wants to merge 2 commits intotokio-rs:masterfrom
pmnoxx:piotr-print-line-number-feature
Closed
Add feature to print line number#1804pmnoxx wants to merge 2 commits intotokio-rs:masterfrom pmnoxx:piotr-print-line-number-feature
pmnoxx wants to merge 2 commits intotokio-rs:masterfrom
pmnoxx:piotr-print-line-number-feature
Conversation
Member
hawkw
added a commit
that referenced
this pull request
Jan 14, 2022
## Motivation Logging line numbers and file names can be useful for debugging. This feature was suggested by #1326 ## Solution As per @hawkw's suggestions, fields were added on `Format`, along with builder methods. Filename and line number information was gathered from the `meta` variable. The `Pretty` formatter already supports printing source locations, but this is configured separately on the `Pretty` formatter rather than on the `Format` type. This branch also changes `Pretty` to honor the `Format`-level configurations and deprecates the `Pretty`-specific method. Fixes #1326 Closes #1804 Co-authored-by: David Barsky <me@davidbarsky.com> Co-authored-by: Eliza Weisman <eliza@buoyant.io>
hawkw
added a commit
that referenced
this pull request
Jan 14, 2022
## Motivation Logging line numbers and file names can be useful for debugging. This feature was suggested by #1326 ## Solution As per @hawkw's suggestions, fields were added on `Format`, along with builder methods. Filename and line number information was gathered from the `meta` variable. The `Pretty` formatter already supports printing source locations, but this is configured separately on the `Pretty` formatter rather than on the `Format` type. This branch also changes `Pretty` to honor the `Format`-level configurations and deprecates the `Pretty`-specific method. Fixes #1326 Closes #1804 Co-authored-by: David Barsky <me@davidbarsky.com> Co-authored-by: Eliza Weisman <eliza@buoyant.io>
kaffarell
pushed a commit
to kaffarell/tracing
that referenced
this pull request
May 22, 2024
…1773) ## Motivation Logging line numbers and file names can be useful for debugging. This feature was suggested by tokio-rs#1326 ## Solution As per @hawkw's suggestions, fields were added on `Format`, along with builder methods. Filename and line number information was gathered from the `meta` variable. The `Pretty` formatter already supports printing source locations, but this is configured separately on the `Pretty` formatter rather than on the `Format` type. This branch also changes `Pretty` to honor the `Format`-level configurations and deprecates the `Pretty`-specific method. Fixes tokio-rs#1326 Closes tokio-rs#1804 Co-authored-by: David Barsky <me@davidbarsky.com> Co-authored-by: Eliza Weisman <eliza@buoyant.io>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
We have been using
tracingfor logging. However, one if it's major drawbacks is inability to display line numbers.When looking at logs I noticed that we spend a huge portion of log to display the target, but the line number is not included,
making the log somewhat useless.
I often use tracing for debugging, and I would prefer to have line numbers written. As a user of
log4j. I know how important line numbers are while debugging issues. It allows to quickly jump to the right line number to see the code, which printed the error, rather than having to search for it. Sometimes, it's not possible to uniquely determine which line logged given message, unless the user specifies it.Solution
Add logging line numbers, for example:
Previously, the message would be:
Notes:
line_numbersare only drawn whendisplay_targetis defined - can be extended to work withoutdisplay_target- as a separate PRQuestions:
with_line_numberstest - what other tests do we need?prettystill printline_numbersif this option is disabled?