loguru icon indicating copy to clipboard operation
loguru copied to clipboard

How to use in multiple modules?

Open rainzee opened this issue 2 years ago • 4 comments

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?

rainzee avatar Jun 04 '23 04:06 rainzee

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 avatar Jun 04 '23 14:06 Delgan

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.

wxguy avatar Jun 22 '23 01:06 wxguy

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

rainzee avatar Jun 22 '23 08:06 rainzee

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.

Delgan avatar Jun 23 '23 09:06 Delgan