onkel-dirtus / logger_file_backend

MIT License
307 stars 128 forks source link

Releasing file descriptor when backend is removed #74

Closed nicogoblin closed 2 years ago

nicogoblin commented 3 years ago

This PR deals with releasing the file descriptor in case the backend has removed.

Linked issue

This PR has linked to this issue #68

Proposed solution

I replicate the problem with the example described in issue #68. The file, in this case, is not released because when the Logger.remove_backend(...) method is invoked the :gen_event behavior does not catch the exit signal in the handle_info callback. The solution I propose is to make a pattern match on the exit signal and in this callback close the file.

Let me know what think about it, I'm happy to help with this project that I find very useful. :D