Mayil-AI-Sandbox / loguru-Jan2023

MIT License
0 stars 0 forks source link

Same log line output twice? (hashtag628) #88

Closed vikramsubramanian closed 2 months ago

vikramsubramanian commented 2 months ago

I add this line below in my code. logger.add(sys.stdout, colorize=True, format="<green><b>{time:YYYY-MM-DD :mm:ss}</b></green> - {level} - {file} - {line} - {message}")

The same log output twice in terminal like:

2022-03-31 18:19:10.853 | INFO | main:main:33 - Set random seed to 1 2022-03-31 :19:10 - INFO - train.py - 33 - Set random seed to 1

vikramsubramanian commented 2 months ago

This is probably because of the default handler added automatically which logs messages to sys.stderr. You need to call [logger.remove()]( first.

vikramsubramanian commented 2 months ago

I think I've seen this question quite a few times, maybe its time to create a FAQ section? Just for reference: hashtag481

vikramsubramanian commented 2 months ago

You're right thanks for the suggestion.

I added it to the "Help & Guides" page of the documentation: [Avoiding logs to be printed twice on the terminal](

Perhaps the "FAQ" format would be more appropriate, but it should be filled with more questions.

vikramsubramanian commented 2 months ago

I can take a look and see if there are any more duplicate questions if you'd like. Having a FAQ section readily available will make onboarding simpler for new python users or users migrating from logging (even though the documentation is already comprehensive IMO).

vikramsubramanian commented 2 months ago

Thank you for your kind offer! I could certainly find a couple of questions that would fit in the FAQ as well. If you have any ideas that could help to grasp Loguru, please don't hesitate. I just wonder if it isn't too much repetition / overload between the already existing "Readme", "Migration" and "Help & Guides" sections (although I agree a FAQ has its own advantages).

vikramsubramanian commented 2 months ago

From the sounds of it, a discussion surrounding documentation architecture might be good. A good start might just include adding a table of contents to the README. What do you think?

vikramsubramanian commented 2 months ago

From the sounds of it, a discussion surrounding documentation architecture might be good. A good start might just include adding a table of contents to the README. What do you think?

Sorry, I forgot to answer you. To be honest, I prefer not to overload the current README. I quite like its relative simplicity with examples and links to the documentation for details.

I'm closing this ticket as I answered the initial question, but a new one can be opened about possible documentation improvements.