Skip to content

Implement log_every_n macro - #3473

Open
soumyasen1809 wants to merge 6 commits into
tokio-rs:mainfrom
soumyasen1809:log_n_3457
Open

soumyasen1809 wants to merge 6 commits into
tokio-rs:mainfrom
soumyasen1809:log_n_3457

Conversation

@soumyasen1809

Copy link
Copy Markdown

Add the log_every_n macro that will log an event after every n steps.
Fixes issue #3457

The pull request introduces a log_every_n! macro designed to address logging overhead in high-throughput systems by logging an event only after a specified number of steps. The macro utilizes std::sync::atomic::AtomicUsize for atomic thread-safety.

Motivation

Potentially improve the performance for heavy logging systems by not spamming the system.

Solution

Add log_every_n macro that logs at every n steps.

Add the log_every_n macro that will log an event after
every n steps.
Fixes issue tokio-rs#3457
@soumyasen1809
soumyasen1809 requested review from a team, hawkw and hds as code owners February 9, 2026 22:09

@dentiny dentiny left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(I'm not repo/org owner) If I were you, I would put a unit test with stream redirection to verify log content.

This branch has not been deployed

No deployments
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.

2 participants