How to handle a (possibly) misbehaving logger?
See original GitHub issueHi Delgan,
In one of my multithreaded service daemons I’m seeing that the logger will occasionally stop altogether. By that I mean the application continues to run as if there are no errors but nothing is written to the logs and the files themselves aren’t rotated. The file descriptors for the log files themselves are still open too. I suspect that I’m either blocking on a single logging call or that the there could have been an exception in the logger itself. Unfortunately I don’t have a record of strerr to check this.
In the interest of debugging my problem I have a couple of questions:
- Do you have an example of handling errors in the Loguru logger (setting
catch
toFalse
when adding a sink) to the documentation? Would this basically mean that every logging call needs to be put into a try/except block? - If there is an exception in the logger, can it be restarted to make it sane again? If so, how can I accomplish that?
- If on the other hand I’m being blocked by a single logging call (not sure why this would be), do you think that setting
enqueue
toTrue
when adding a sink might solve my problem? Do logging calls eventually timeout?
I use Loguru extensively in my work. Thanks for your effort!
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Logging Best Practices: The 13 You Should Know - DataSet
1. Don't Write Logs by Yourself (AKA Don't Reinvent the Wheel) ... Never, ever use printf or write your log entries to files...
Read more >What to do with a misbehaving BIND server
Here are some things that we'd recommend you do as many of as possible before attempting to clear the problem - and then...
Read more >Bad Behavior in the Workplace? Here Are 10 Ways to Deal
Show that you're serious about what is and isn't bad behavior at work, as well as what the consequences are. Warnings, reprimands, unpaid...
Read more >Quick And Dirty Python Logging Lesson - Nathaniel Brown's
Logging should be easy. If you are overwhelmed with logging output you can't filter or turn off, or you don't know how to...
Read more >Where to handle IOException when adding a file handler to a ...
final also ensures that some misbehaving part of the code doesn't change the value of the logger or set it to null ....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I assumed this was the case, but failed to find anything from the Python stdlib documentation listing this requirement (not sure if re-entrant signal handlers are the norm across all programming languages).
Your explanation makes sense. Don’t worry about coming up with a fix. I’ve already removed the logging calls from my
signal
handlers, but a note in the documentation might save clueless people like me some time!Thanks again Delgan and great work on Loguru!
Actually, I’ve managed to reproduce and I think what I’ve found constitutes a separate issue. I will raise and link it here. EDIT: https://github.com/Delgan/loguru/issues/712