Skip to content

create a proper Logfire type #87

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

Merged
merged 1 commit into from
Aug 4, 2025
Merged

create a proper Logfire type #87

merged 1 commit into from
Aug 4, 2025

Conversation

davidhewitt
Copy link
Contributor

This changes the result of calling logfire::configure().finish() to produce a Logfire struct.

The on-drop-shutdown semantics are moved to a ShutdownGuard type, which is accessible by calling logfire.shutdown_guard() on a Logfire struct.

I think this cleans up the public API and makes it possible to be deliberate about where to install the guard. The previous ShutdownHandler type was doing too many things.

As part of this cleanup I've moved a lot of code out of lib.rs and into either config.rs or a new logfire.rs file.

@@ -72,7 +73,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.run()
.await?;

shutdown_handler.shutdown()?;
// Shutdown handled automatically by the guard
Copy link
Member

Choose a reason for hiding this comment

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

Nice


/// Builder for logfire configuration, returned from [`logfire::configure()`][crate::configure].
#[derive(Default)]
#[must_use = "call `.finish()` to complete logfire configuration."]
Copy link
Member

Choose a reason for hiding this comment

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

💯

@davidhewitt davidhewitt merged commit 5a4ed0d into main Aug 4, 2025
7 checks passed
@davidhewitt davidhewitt deleted the dh/logfire-type branch August 4, 2025 14:25
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