Skip to content
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

Allow forking from existing loggers #15

Merged
merged 3 commits into from
Oct 12, 2022
Merged

Allow forking from existing loggers #15

merged 3 commits into from
Oct 12, 2022

Conversation

SpriteOvO
Copy link
Owner

@SpriteOvO SpriteOvO commented Oct 10, 2022

Closes #13.

To avoid confusion with the semantics of Arc::clone, I have named the new methods as fork_xxx.

Unsolved Questions

  • Not sure if fn fork(self: &Arc<Self>) -> Result<Arc<Self>> (no modifier, just fork as is) is also necessary to add.

@SpriteOvO SpriteOvO added the enhancement New feature or request label Oct 10, 2022
@SpriteOvO SpriteOvO added this to the v0.3.0 milestone Oct 10, 2022
@SpriteOvO SpriteOvO requested a review from Lancern October 10, 2022 15:07
Comment on lines 281 to 284
/// Fork and configure a separate new logger.
///
/// The new logger will be detached from the `Arc` sharing relationship with
/// the old logger and become a separate object.
Copy link
Collaborator

Choose a reason for hiding this comment

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

The meaning of "fork" should be further clarified:

Fork and configure a separate new logger.

This function creates a new logger object that inherits logger properties from self. Then this function calls the given modifier function which configures the properties on the new logger object. The created new logger object will be a separate object from self.

Copy link
Owner Author

@SpriteOvO SpriteOvO Oct 11, 2022

Choose a reason for hiding this comment

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

I think it would be better to replace self in your suggestion with Arc<Self>.

This function creates a new logger object that inherits logger properties from Arc<Self>. Then this function calls the given modifier function which configures the properties on the new logger object. The created new logger object will be a separate object from Arc<Self>. (No ownership sharing)

Copy link
Collaborator

@Lancern Lancern left a comment

Choose a reason for hiding this comment

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

LGTM.

@Lancern
Copy link
Collaborator

Lancern commented Oct 12, 2022

Not sure if fn fork(self: &Arc<Self>) -> Result<Arc<Self>> (no modifier, just fork as is) is also necessary to add.

I can't imagine a use case for this function. Is it necessary? What's the use case?

@SpriteOvO
Copy link
Owner Author

Not sure if fn fork(self: &Arc<Self>) -> Result<Arc<Self>> (no modifier, just fork as is) is also necessary to add.

I can't imagine a use case for this function. Is it necessary? What's the use case?

I can't either. So let's not implement it and wait for a feature request to be opened by someone who needs it.

@SpriteOvO SpriteOvO merged commit 6c13c37 into main Oct 12, 2022
@SpriteOvO SpriteOvO deleted the fork-logger branch October 12, 2022 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Create logger builders from existing loggers
2 participants