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

Allow custom formatting #37

Merged
merged 12 commits into from
Jul 4, 2023
Merged

Allow custom formatting #37

merged 12 commits into from
Jul 4, 2023

Conversation

mendelsshop
Copy link
Contributor

This lets you use

#[trace(format_enter="a is {a} ...")
fn foo(a: u32) {
}

So for example, when you call foo with 1 it will print: Entering foo(a is 1 ...).
Currently, it is combined with prefix_enter or prefix_exit when printing.
You can also do custom formatting for when a function exits with format_exit.
For example, #[trace(format_enter="returning {r} ..."), r is used to denote
when to interpolate the return value, but it is easy to change to a different symbol.
This technically fixes #30, because you can do #[trace(format_exit=""),
and not interpolate anything.
Generally, the formatting follows the same rules and produces the same errors as format!,
but it does not (yet) allow for anything past basic interpolation, like pretty printing or padding.
Note: format_enter and or format_exit cannot be used with pretty.

Copy link
Owner

@gsingh93 gsingh93 left a comment

Choose a reason for hiding this comment

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

I don't have time to do a thorough review, but looks good after a quick skim and the tests pass, so approved. Thanks!

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@gsingh93 gsingh93 merged commit d8c2d94 into gsingh93:master Jul 4, 2023
2 checks passed
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.

Disable return value
2 participants