Skip to content

tracing: simplify level event macros#3441

Open
hds wants to merge 1 commit into
hds/macro-genfrom
hds/simplify-level-event-macros
Open

tracing: simplify level event macros#3441
hds wants to merge 1 commit into
hds/macro-genfrom
hds/simplify-level-event-macros

Conversation

@hds
Copy link
Copy Markdown
Contributor

@hds hds commented Dec 17, 2025

Motivation

The level event macros (e.g. trace!, info!) call into the event!
macro with the level set appropriately. However, these macros have
become complex, covering many different cases and reaching aroudn 250
lines of patterns.

As discovered in #3437, there were many cases where these level event
macros didn't correctly handle patterns which the event! macro does
handle.

Solution

This change simplifies the event macros to delegate more parsing to the
common event! macro patterns. Rather than matching all the possible
field patterns, the level event macros only match the directives (name,
target, and parent or some combination thereof). The remainder of the
macro invocation is matched as a token tree (tt) and passed as is to
the event! macro.

This reduces the patterns to only the 8 combinations of directives
(including no directives at all), reducing the previous 250 lines of
patterns for each macro down to around 25 lines instead.

Additionally, an unqualified use of Some in the valueset macro has
been fixed, as this affected all event macros (event! and all the
level event macros).

With these changes, the comprehensive checks introduced in #3437 now all
pass and so the job can be fully enabled to fail on CI.

@hds hds requested review from a team and hawkw as code owners December 17, 2025 22:31
@hds hds marked this pull request as draft December 17, 2025 22:31
@hds hds changed the base branch from main to hds/macro-gen December 18, 2025 14:19
@hds hds force-pushed the hds/simplify-level-event-macros branch 2 times, most recently from cd5fd4f to 2ee3d9c Compare December 18, 2025 14:22
@hds hds marked this pull request as ready for review December 18, 2025 14:55
The level event macros (e.g. `trace!`, `info!`) call into the `event!`
macro with the level set appropriately. However, these macros have
become complex, covering many different cases and reaching aroudn 250
lines of patterns.

As discovered in #3437, there were many cases where these level event
macros didn't correctly handle patterns which the `event!` macro does
handle.

This change simplifies the event macros to delegate more parsing to the
common `event!` macro patterns. Rather than matching all the possible
field patterns, the level event macros only match the directives (name,
target, and parent or some combination thereof). The remainder of the
macro invocation is matched as a token tree (`tt`) and passed as is to
the `event!` macro.

This reduces the patterns to only the 8 combinations of directives
(including no directives at all), reducing the previous 250 lines of
patterns for each macro down to around 25 lines instead.

Additionally, an unqualified use of `Some` in the `valueset` macro has
been fixed, as this affected all event macros (`event!` and all the
level event macros).

With these changes, the comprehensive checks introduced in #3437 now all
pass and so the job can be fully enabled to fail on CI.
@hds hds force-pushed the hds/simplify-level-event-macros branch from 2ee3d9c to 78d2af6 Compare December 18, 2025 15:05
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.

1 participant