Skip to content

Comments

feat: allow manually shutting down logging from TelemetryDriver#168

Closed
AkshatM wants to merge 0 commit intocloudflare:mainfrom
AkshatM:main
Closed

feat: allow manually shutting down logging from TelemetryDriver#168
AkshatM wants to merge 0 commit intocloudflare:mainfrom
AkshatM:main

Conversation

@AkshatM
Copy link
Contributor

@AkshatM AkshatM commented Feb 12, 2026

Fixes #114, which describes the bug in detail. slog provides an AsyncGuard implementation which is designed to ensure log flushes on drops even if the Async logger is captured in a global variable.

To ensure backwards compatibility, we now return an AsyncGuard that can be manually dropped, allowing existing users to continue to rely on current semantics but guarantee logging is shut down when desired. Credit to @TheJokr for the suggestion.

The most complicated part of this feature is its interaction with the logging feature. Since it only makes sense if logging is enabled, I have conditionally compiled accordingly.

@AkshatM AkshatM force-pushed the main branch 3 times, most recently from 014fd09 to 4c1e7ee Compare February 12, 2026 15:58
@TheJokr TheJokr self-requested a review February 13, 2026 11:55
@AkshatM
Copy link
Contributor Author

AkshatM commented Feb 13, 2026

Received confirmation from @hanglowan that this fix resolves the log flush behaviour as expected by calling driver.shutdown_logger() as described before program exit. Thanks for re-discovering and validating the fix, Hannah!

Copy link
Collaborator

@TheJokr TheJokr left a comment

Choose a reason for hiding this comment

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

Thank you! LGTM, just some nits.

@AkshatM
Copy link
Contributor Author

AkshatM commented Feb 17, 2026

@TheJokr I done goofed. I had to reopen this PR at #172. But it address all feedback.

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.

Logs may be discarded if the program exits before AsyncDrain can write

2 participants