Skip to content

Conversation

@michaelbeaumont
Copy link

@michaelbeaumont michaelbeaumont commented Apr 18, 2025

Motivation

Fixes #1311

There's currently no way to use {:#} to format a field, which is very important for anyhow::Error in particular.

Of course this should be backported v0.1

Solution

Add a new sigil %%. I had parsing issues with # so I quickly abandoned that, though there may be a way to make it work. I'm not attached to this particular sigil at all.

Add a new wrapper similar to DisplayValue that formats with the alternate # flag. The solution I have is use format_args!, this should be OK AFAICT. I think ideally we would use the Formatter API to just switch on alternate, but it's nightly only.

@michaelbeaumont michaelbeaumont force-pushed the feat/alternate-display-field branch from d849f38 to 5c6b8f3 Compare April 18, 2025 16:21
Copy link
Contributor

@hds hds 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 see anything in this change that looks like it's changing the behavior of the event and span macros to accept a %% prefix.

Is there something that wasn't added to the change?

(Caveat: I haven't actually tested the change, but without modifying the declarative macros I don't see how the new prefix could work)

Could you please clarify this?

@michaelbeaumont
Copy link
Author

but without modifying the declarative macros

Maybe I'm missing something but all changes in tracing/src/macros.rs? @hds

@hds
Copy link
Contributor

hds commented Nov 23, 2025

Yeah. I'm expecting changes in there. And some tests to go with it.

Also, fair warning, we've recently found some inconsistencies in those macros and different field patterns.

It needs to be cleaned up and covered in more comprehensive tests. To keep things sane, we probably won't merge this PR until that's done.

@michaelbeaumont
Copy link
Author

Yeah. I'm expecting changes in there. And some tests to go with it.

Yeah, they're in the PR already though.

@michaelbeaumont michaelbeaumont requested a review from hds November 24, 2025 14:15
@michaelbeaumont
Copy link
Author

@hds the changes you requested were already part of the PR

@hds
Copy link
Contributor

hds commented Dec 11, 2025

@michaelbeaumont Sorry about that! I missed the changes as they were automatically folded up by GitHub. I'll have a look at this one, but after we make some general fixes to the macros where we've got a bunch of inconsistencies.

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.

Introduce a formatter sigil for "alternate" Display

2 participants