easyloggingpp
easyloggingpp copied to clipboard
Enable reopening log files
Once a Logger is configured the application keeps the file open. This is due to that LogStreamReferenceMap
is keeping a reference to the FileStream object and unregistering the Logger will never close the file.
Switching to weak_ptr in LogStreamReferenceMap
i.e. not holding a reference makes unregistering logger close the file if no other reference to FileStream object exist.
The use case is for logrotation where logrotation removes the logfile and sends a SIGHUP to the application. This fix makes it possible to reconfigure the logger to reopen the log file. I added a sample to illustrate the use case.
This is a
- [ ] Breaking change
- [ ] New feature
- [x] Bugfix
I have
- [x] Merged in the latest upstream changes
- [ ] Updated
CHANGELOG.md
- [ ] Updated
README.md
- [x] Run the tests
Apparently unit test fails, I haven't looked at them yet. Any comment on this change, does it break the architecture? Or is it just the tests that need to be updated?
Tests passes when I run them locally with my latest update.
Travis CI build seem to have some problem with cmake when building googletest.
I would love to see this added, as without using the linux logrotate
utility is impossible, as that relies on the program being able to close and reopen the log file.