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

How to use in multiple modules? #886

Open
rainzee opened this issue Jun 4, 2023 · 4 comments
Open

How to use in multiple modules? #886

rainzee opened this issue Jun 4, 2023 · 4 comments
Labels
question Further information is requested

Comments

@rainzee
Copy link

rainzee commented Jun 4, 2023

For example I have this project which contains log.py main.py core.py and I want to configure my logger in log.py and use it in main and core modules, what is the best practice? Any examples?

@Delgan
Copy link
Owner

Delgan commented Jun 4, 2023

You just have to do from loguru import logger in all of your modules.

I suggest the logger to be configured by the entry point of your application, which I assume is main.py.

@Delgan Delgan added the question Further information is requested label Jun 4, 2023
@wxguy
Copy link

wxguy commented Jun 22, 2023

You just have to do from loguru import logger in all of your modules.

I suggest the logger to be configured by the entry point of your application, which I assume is main.py.

This should have been included as part of official documentation. Wasted my time by many hours to search answer for this same question until I found this issue.

Strongly recommended for inclusion in official documentation.

@rainzee
Copy link
Author

rainzee commented Jun 22, 2023

I think the official documentation should give some best practices in the project

@Delgan
Copy link
Owner

Delgan commented Jun 23, 2023

Hi @wxguy and @rainzee.

There exists actually an entry in the documentation that gives an overview of the recommended structure: Configuring Loguru to be used by a library or an application.

Feel free to suggest improvements and clarifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants