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

improve library disable readme #883

Merged
merged 4 commits into from
Jun 2, 2023
Merged

improve library disable readme #883

merged 4 commits into from
Jun 2, 2023

Conversation

trim21
Copy link
Contributor

@trim21 trim21 commented Jun 1, 2023

Original example is a little bit confusing, is take me a while to figure out that I need to disable library's __name__ instead of name I used in logger.bind(name='my_library')

@Delgan
Copy link
Owner

Delgan commented Jun 2, 2023

Hi @trim21, thanks for the improvement suggestion.

Could you please clarify your use case?
I have trouble understand why you would need to use __name__.

What I mean by "library" is some module intended to be used as an external source (after being installed). If the module is part of a project, it does not need to call logger.disable(), it can be configured at the entry point of the project instead.

@trim21
Copy link
Contributor Author

trim21 commented Jun 2, 2023

Hi @trim21, thanks for the improvement suggestion.

Could you please clarify your use case? I have trouble understand why you would need to use __name__.

I'm using loguru in my library and I find that I didn't actually disable it because I'm using the wrong name.

For your example, pip install my-library, and in the code, I should call logger.disable('my_library') instead of my-library, or logger.disable('my-library-2') for logger.bind(name='my-library-2')

@Delgan
Copy link
Owner

Delgan commented Jun 2, 2023

Ok, I see, thanks.

I think suggesting logger.disable(__name__) can be confusing as well, because the result will depend on where it's called from (while using a static name like "my_library" is less error-prone in my opinion).

Can you please change your commit so that the only change is:

logger.disable("my_library")  # Should be your library's `__name__` 

I think it helps clarify usage, right?

@Delgan Delgan merged commit 4eba4bd into Delgan:master Jun 2, 2023
15 checks passed
@Delgan
Copy link
Owner

Delgan commented Jun 2, 2023

Thank you!

@trim21 trim21 deleted the patch-1 branch June 2, 2023 09: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.

None yet

2 participants